kou commented on code in PR #38885:
URL: https://github.com/apache/arrow/pull/38885#discussion_r1413565985
##########
cpp/src/arrow/dataset/dataset_writer.cc:
##########
@@ -621,11 +621,21 @@ class DatasetWriter::DatasetWriterImpl {
backpressure = writer_state_.open_files_throttle.Acquire(1);
if (!backpressure.is_finished()) {
EVENT_ON_CURRENT_SPAN("DatasetWriter::Backpressure::TooManyOpenFiles");
+
writer_state_.rows_in_flight_throttle.Release(next_chunk->num_rows());
RETURN_NOT_OK(TryCloseLargestFile());
break;
}
}
- RETURN_NOT_OK(dir_queue->StartWrite(next_chunk));
+ auto s = dir_queue->StartWrite(next_chunk);
+ if (!s.ok()) {
+ // If `StartWrite` succeeded, it will Release the
+ // `rows_in_flight_throttle` when the write task is finished.
+ //
+ // `open_files_throttle` will be handed by
`DatasetWriterDirectoryQueue`
+ // so we don't need to release it here.
+ writer_state_.rows_in_flight_throttle.Release(next_chunk->num_rows());
Review Comment:
Thanks. I tried again without this change:
```diff
diff --git a/cpp/src/arrow/dataset/dataset_writer.cc
b/cpp/src/arrow/dataset/dataset_writer.cc
index ae9fb3648..c38e899ab 100644
--- a/cpp/src/arrow/dataset/dataset_writer.cc
+++ b/cpp/src/arrow/dataset/dataset_writer.cc
@@ -633,7 +633,7 @@ class DatasetWriter::DatasetWriterImpl {
//
// `open_files_throttle` will be handed by
`DatasetWriterDirectoryQueue`
// so we don't need to release it here.
-
writer_state_.rows_in_flight_throttle.Release(next_chunk->num_rows());
+ //
writer_state_.rows_in_flight_throttle.Release(next_chunk->num_rows());
return s;
}
batch = std::move(remainder);
```
And the added test is still passing.
Is it difficult to write a test for this change too? If it's difficult,
I'll merge this without a test for this change.
(I confirmed that the added test hanged without another change
https://github.com/apache/arrow/pull/38885/files#diff-387ad04c2450a38044e667e07183b8265866cb3736d10acdce137c2b83737b16R624
.)
--
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]