kou commented on code in PR #38885:
URL: https://github.com/apache/arrow/pull/38885#discussion_r1405564397
##########
cpp/src/arrow/dataset/dataset_writer.cc:
##########
@@ -621,11 +621,18 @@ 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.
+ writer_state_.rows_in_flight_throttle.Release(next_chunk->num_rows());
Review Comment:
Could you add the note as a comment?
##########
cpp/src/arrow/dataset/dataset_writer.cc:
##########
@@ -621,11 +621,18 @@ 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());
Review Comment:
Can we move the `rows_in_flight_throttle.Acquire()` call to close to the
existing `rows_in_flight_throttle.Release()` call and this `Release()` call to
there? (`DatasetWriterFileQueue`?)
I think that the `Acquire()`/`Release()` pair should be close for easy to
maintain like `malloc()`/`free()` pair and `new`/`delete` pair.
(Can we apply the same approach to the
`open_files_throttle.Acquire()`/`Release()` pair too?)
--
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]