thisisnic commented on issue #34402:
URL: https://github.com/apache/arrow/issues/34402#issuecomment-7171748959

   `DoPut` is a streaming call, so `client->DoPut()` returns once the stream is 
opened, without waiting for the server's handler to respond. The server's 
status is delivered when the stream ends, which is why it surfaces from 
`writer->Close()` (or from a later write, once the client has noticed the 
stream is gone).
   
   To find out whether the server accepted the call before sending any data, 
have the server send an acknowledgement and read it on the client first:
   
   - Server: once the request is validated, call `writer->WriteMetadata(...)` 
before reading any batches.
   - Client: call `result.reader->ReadMetadata(&buf)` straight after `DoPut()`. 
If `buf` is null, the server ended the call without acknowledging; call 
`writer->Close()` to get its error. Otherwise, go ahead and write.
   
   The server has to acknowledge every call it accepts. If it accepts without 
writing metadata, the client's `ReadMetadata` waits until the call's deadline, 
because the server is waiting for data at the same time. With default 
`FlightCallOptions` (no timeout set) it was still waiting when I stopped it 
after 8 s.
   
   I ran a client following the code in this issue against a server like the 
one above, built against Arrow C++ 26.0.1, with a 3 s call timeout:
   
   | Client does | Server rejects | Result |
   |---|---|---|
   | `DoPut`, write, `DoneWriting`, `Close` (as in the report) | yes | all OK 
until `Close`, which returns "Testing DoPut failure" |
   | `DoPut`, wait 500 ms, write | yes | the write returns "Testing DoPut 
failure" |
   | `DoPut`, `ReadMetadata`, `Close` | yes | `ReadMetadata` returns OK with a 
null buffer; `Close` returns "Testing DoPut failure"; no data sent |
   | `DoPut`, `ReadMetadata`, write, `DoneWriting`, `Close` | no, and 
acknowledges | `ReadMetadata` returns the acknowledgement; everything OK |
   | `DoPut`, `ReadMetadata`, write | no, but doesn't acknowledge | 
`ReadMetadata` waits for the 3 s timeout, then the write fails with "Deadline 
Exceeded" |
   
   I've relabelled this as a usage question and am closing it as answered. If 
the doc comment for `FlightClient::DoPut` should spell out where server errors 
surface, that would be worth a separate issue.
   


-- 
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