hello-stephen commented on code in PR #71103:
URL: https://github.com/apache/doris/pull/71103#discussion_r4736010290


##########
be/src/storage/segment/variant/v2/variant_column_writer.cpp:
##########
@@ -248,9 +250,27 @@ Status VariantV2ColumnWriter::_write_materialized(const 
VariantShreddedColumns&
         RETURN_IF_ERROR(variant_writer_helpers::append_sparse_column(
                 tablet_column, writer.get(), path_column.type, 
path_column.column,
                 path_column.rowids, _num_rows));
-        _subcolumn_indexes.push_back(std::move(indexes));
-        _subcolumn_opts.push_back(opts);
-        _subcolumn_writers.push_back(std::move(writer));
+        // Drain this path before the next writer allocates its page and index 
builders.
+        RETURN_IF_ERROR(writer->finish());
+        RETURN_IF_ERROR(writer->write_data());
+        _materialized_raw_data_bytes += writer->get_raw_data_bytes();
+        _materialized_uncompressed_data_bytes += 
writer->get_total_uncompressed_data_pages_bytes();
+        _materialized_compressed_data_bytes += 
writer->get_total_compressed_data_pages_bytes();
+        const uint64_t index_start = _opts.file_writer->bytes_appended();
+        RETURN_IF_ERROR(writer->write_ordinal_index());
+        if (opts.need_zone_map) {
+            RETURN_IF_ERROR(writer->write_zone_map());
+        }
+        if (opts.need_bloom_filter) {
+            RETURN_IF_ERROR(writer->write_bloom_filter_index());
+        }
+        if (_opts.inline_index_bytes != nullptr) {
+            *_opts.inline_index_bytes += _opts.file_writer->bytes_appended() - 
index_start;
+        }
+        if (opts.need_inverted_index) {
+            // Finalize the column index while the segment still owns its 
files for packing.
+            RETURN_IF_ERROR(writer->write_inverted_index());

Review Comment:
   [P2] Preserve abort cleanup for completed path indexes
   
   With V2 text path indexes and `inverted_index_ram_dir_enable=false`, 
finishing here resets CLucene's `_index_writer`, so destroying the path writer 
no longer calls `close_on_error()` to delete its temporary directory. If a 
later column fails during `write_block()` (for example its disk-capacity 
check), `SegmentFlusher` returns before `close_inverted_index()`. Both 
`IndexFileWriter` and `DorisFSDirectory` have default destructors, so completed 
path indexes remain under the configured temporary directory until BE restart. 
Previously the still-unfinished path writers deleted those directories on the 
same failure. Repeated failed loads can therefore accumulate index files and 
worsen disk pressure. Please retain abort cleanup for completed paths until 
their container is packed, and cover this later-write failure with disk-backed 
indexes.



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