pitrou commented on code in PR #41876:
URL: https://github.com/apache/arrow/pull/41876#discussion_r1633301388
##########
cpp/src/arrow/filesystem/s3fs.cc:
##########
@@ -1892,6 +1896,9 @@ class ObjectOutputStream final : public io::OutputStream {
}
// Notify completion
if (--state->parts_in_progress == 0) {
+ // GH-41862: avoid potential deadlock if the Future's callback is called
+ // with the mutex taken.
+ lock.unlock();
state->pending_parts_completed.MarkFinished(state->status);
Review Comment:
Um, you're right. @mapleFU's suggestion looks ok to me.
Note that the `pending_parts_completed` future can only be waited on in two
situations:
* the user called blocking `Close` or `Flush` and the future is waited upon
before returning from the API call;
* the user called non-blocking `CloseAsync`, which returns a cascaded future
obtained by chaining `pending_parts_completed.Then` with a continuation.
For `Close` and `CloseAsync`, it's certainly not ok to call `Write` from
another thread concurrently.
For `Flush`, it should be ok to call `Write` concurrently, but the `Flush`
does not have to wait for the completion of the concurrent `Write` call.
Moreover, more generally, it doesn't seem sound to write to an output
_stream_ (rather than random-access file) from several thread concurrently.
--
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]