fix: add buffer flushing to filesystem writes #1911
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Current implementation of
ObjectOutputStream
does not invoke flush when writing out files to Azure storage which seem to cause intermittent issues when thewrite_deltalake
hangs with no progress and no error.I'm adding a periodic flush to the write process, based on the written buffer size, which can be parameterized via
storage_options
parameter (I could not find another way without changing the interface). I don't know if this is an acceptable approach (also, it requires string values)Setting the
"max_buffer_size": f"{100 * 1024}"
instorage_options
passed towrite_deltalake
helps me resolve the issue with writing a dataset to Azure which was otherwise failing constantly.Default max buffer size is set to 4MB which looks reasonable and used by other implementations I've seen (e.g. https://github.com/fsspec/filesystem_spec/blob/3c247f56d4a4b22fc9ffec9ad4882a76ee47237d/fsspec/spec.py#L1577)
Related Issue(s)
Can help with resolving #1770
Documentation
If the approach is accepted then I need to find the best way of adding this to docs