Copilot commented on code in PR #59011:
URL: https://github.com/apache/doris/pull/59011#discussion_r2614554938


##########
be/src/olap/rowset/segment_creator.cpp:
##########
@@ -111,7 +111,13 @@ Status 
SegmentFlusher::_internal_parse_variant_columns(vectorized::Block& block)
 }
 
 Status SegmentFlusher::close() {
-    return _seg_files.close();
+    RETURN_IF_ERROR(_seg_files.close());
+    for (const auto& [seg_id, idx_writer_ptr] : _idx_files.get_file_writers()) 
{
+        if (idx_writer_ptr != nullptr && idx_writer_ptr->get_file_writer() != 
nullptr) {
+            RETURN_IF_ERROR(idx_writer_ptr->get_file_writer()->close());

Review Comment:
   The file writer should be checked for state before calling close() to avoid 
potential double-close issues. The FSIndexOutputV2::close() method 
(inverted_index_fs_directory.cpp:436) calls _index_v2_file_writer->close(true), 
and calling close() again without checking the writer's state may return 
ALREADY_CLOSED errors in some scenarios. Consider checking writer->state() != 
io::FileWriter::State::CLOSED before closing, similar to the pattern used in 
SegmentFileCollection::close() at beta_rowset_writer.cpp:137.
   ```suggestion
               auto* file_writer = idx_writer_ptr->get_file_writer();
               if (file_writer->state() != io::FileWriter::State::CLOSED) {
                   RETURN_IF_ERROR(file_writer->close());
               }
   ```



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to