-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Storage] Fix spill/restore error when using Arrow S3FS #24196
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice find! I think you might be able to test this in CI with the ray_storage_object_spilling_config
fixture. Can you try that out on one of the object spilling tests? If not, it's okay for now.
@stephanie-wang I think this is already covered by existing tests? The issue occurs quite rarely even when using S3. I can add a test for ray_storage + S3 since it looks like that path is not tested yet. |
Hmm what do you mean that it was already covered? Do you mean we have existing CI tests that failed with the same error? Probably we don't want to depend on S3 in CI tests, but I think I saw this error before using ray_storage and the local filesystem. |
@stephanie-wang I see. I can add a test using the local filesystem then. I originally thought the |
Triggering rebuild. |
Test_object_spilling seems to be failing on the windows build. Maybe either try to fix or disable it there? |
Why are these changes needed?
This PR fixes two issues.
ValueError: Obtained data has a size of 100102955, although it is supposed to have the size of 100115855.
This is usually because the offset in the object URI is wrong.The fix is twofold: 1. manually call
f.flush()
because Arrow's S3FS is not guaranteed to flush the output when closing (https://github.com/apache/arrow/blob/master/python/pyarrow/io.pxi#L99), and 2. replacef.tell()
with manually adding the written bytes to the offset, becausef.write()
is asynchronous in S3FS and as such thetell()
position is not advanced at this point in the code.ExternalStorageRayStorageImpl
. This causes unnecessary extra S3 requests, costing time and money.By opening the input stream with a buffer size set (https://github.com/apache/arrow/blob/master/python/pyarrow/_fs.pyx#L618), Arrow will buffer the reads and increase I/O efficiency.
The solution is not very pretty right now because we use a private Arrow API. But this is not avoidable until Arrow provides a
seek()
method forBufferedInputStream
. I opened an issue here https://issues.apache.org/jira/projects/ARROW/issues/ARROW-16351.UPDATE: Reverted (2) for now since it is not running stably.
Related issue number
Checks
scripts/format.sh
to lint the changes in this PR.