hcrosse opened a new issue, #912:
URL: https://github.com/apache/arrow-rs-object-store/issues/912

   **Describe the bug**
   
   
[`HttpError::reqwest`](https://github.com/apache/arrow-rs-object-store/blob/c216edef0ac3d0d39da5bcdfeed3dcd034e26597/src/client/http/connection.rs#L122-L128)
 maps `hyper::Error::is_incomplete_message()` to `HttpErrorKind::Request`, 
which 
[`RetryableRequest::send`](https://github.com/apache/arrow-rs-object-store/blob/c216edef0ac3d0d39da5bcdfeed3dcd034e26597/src/client/retry.rs#L457-L463)
 unconditionally retries (`HttpErrorKind::Connect | HttpErrorKind::Request => 
true`) even when `is_idempotent` is `false`.
   
   `hyper::Error::is_incomplete_message()` fires when the remote peer closes 
the connection with EOF after the request has already been written on the wire, 
before or during the response. Unlike `std::io::ErrorKind::UnexpectedEof` and 
`ConnectionReset` right below it in 
[`HttpError::reqwest`](https://github.com/apache/arrow-rs-object-store/blob/c216edef0ac3d0d39da5bcdfeed3dcd034e26597/src/client/http/connection.rs#L129-L138),
 which map to `HttpErrorKind::Interrupted` and only retry when `is_idempotent` 
is `true`, `is_incomplete_message()` retries non idempotent writes such as 
`PutMode::Create` (`If-None-Match: *`) or `PutMode::Update`.
   
   When a server or proxy commits a `PutMode::Create` request and then closes 
the TCP connection without sending response headers, the retry hits `412 
Precondition Failed` and converts an ambiguous transport failure into a 
spurious `Error::AlreadyExists`. Downstream table formats that rely on 
`PutMode::Create` for atomic commits can misinterpret that `AlreadyExists` as a 
concurrent writer commit and either duplicate writes or fail an already 
committed transaction.
   
   **To Reproduce**
   
   1. Configure an `AmazonS3` store with `S3ConditionalPut::ETagMatch` and 
`RetryConfig` (`max_retries >= 1`) pointing at an HTTP server.
   2. On the first `PUT` with `If-None-Match: *`, read the full request headers 
and body, record the object as committed, and drop the TCP stream cleanly 
without writing a response. On a second `PUT` for the same key with 
`If-None-Match: *`, return `412 Precondition Failed`.
   3. Call `store.put_opts(&path, payload, 
PutOptions::from(PutMode::Create)).await`.
   4. Observe that `object_store` sends a second `PUT` and returns 
`Error::AlreadyExists` instead of returning the transport error from the first 
attempt.
   
   **Expected behavior**
   
   `hyper::Error::is_incomplete_message()` should be classified as 
`HttpErrorKind::Interrupted`, matching `std::io::ErrorKind::UnexpectedEof` and 
`ConnectionReset`. Safe methods (`GET`, `HEAD`) and explicitly idempotent 
writes (`PutMode::Overwrite`) continue to retry, while non idempotent writes 
(`PutMode::Create`, `PutMode::Update`) fail fast with 
`HttpErrorKind::Interrupted` rather than retrying after an ambiguous connection 
close.
   
   **Additional context**
   
   This reproduces on `main` (`0.14.2`).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to