apache / apache/arrow-rs-object-store
AsyncRead/AsyncWrite Poisoning Behaviour
- Dominant language
- Rust
- Stars
- 322
- Forks
- 212
- Avg merge
- 5d 2h
- Merged PRs (30d)
- 10
Description
**Is your feature request related to a problem or challenge? Please describe what you are trying to do.**
Currently where ObjectStore exposes APIs in terms of tokio's `AsyncWrite` and `AsyncRead`, any error poisons the entire operation. Subsequent attempts to read/write will likely result in a panic. This is not well documented, and may not be ideal.
**Describe the solution you'd like**
At the very least we should document the current behaviour, but it is unclear, at least to me, what the "correct" behaviour here even is:
`AsyncWrite::poll_write` returns when the bytes have been "written" to the writer, including potentially to an in-flight buffer, see [here](https://docs.rs/tokio/latest/src/tokio/io/util/buf_writer.rs.html#119-134). In the case of `WriteMultiPart` this means `AsyncWrite::poll_write` returns `Ok` before any network to actually write the data to object storage.
Any errors will therefore be surfaced in `AsyncWrite::poll_flush` or `AsyncWrite::poll_shutdown`, which presents a few problems:
* The `PutPart` implementation retries intermittent errors based on the `RetryConfig`, and so we **must** surface any errors to the user
* It is unclear how the caller can determine from the error what byte range needs to be retried, as part uploads are chunked and parallel
* It is unclear how the caller could retry this byte range even if it could be ascertained
This all makes me think that the current behaviour is probably the best we can do, short of not using the tokio IO traits, but I wonder if others have any thoughts on this
**Describe alternatives you've considered**
**Additional context**
Contributor guide
Research direction
Start by tracing ObjectStore's AsyncRead/AsyncWrite implementations, especially WriteMultiPart and PutPart, and inspect how RetryConfig errors surface from poll_flush and poll_shutdown. Compare the current behavior with Tokio's AsyncWrite contract; done requires an agreed behavior or explicit documentation, plus tests if the chosen change affects observable errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100