chaoyli commented on a change in pull request #898: Fix writer add_rowset bug URL: https://github.com/apache/incubator-doris/pull/898#discussion_r274004642
########## File path: be/src/olap/rowset/alpha_rowset_writer.cpp ########## @@ -115,38 +116,49 @@ OLAPStatus AlphaRowsetWriter::add_row_block(RowBlock* row_block) { } OLAPStatus AlphaRowsetWriter::add_rowset(RowsetSharedPtr rowset) { + _need_column_data_writer = false; // this api is for LinkedSchemaChange // use create hard link to copy rowset for performance // this is feasible because LinkedSchemaChange is done on the same disk AlphaRowsetSharedPtr alpha_rowset = std::dynamic_pointer_cast<AlphaRowset>(rowset); for (auto& segment_group : alpha_rowset->_segment_groups) { + RETURN_NOT_OK(_init()); RETURN_NOT_OK(segment_group->copy_segments_to_path(_rowset_writer_context.rowset_path_prefix, _rowset_writer_context.rowset_id)); _cur_segment_group->set_empty(segment_group->empty()); _cur_segment_group->set_num_segments(segment_group->num_segments()); _cur_segment_group->add_zone_maps_for_linked_schema_change(segment_group->get_zone_maps()); - RETURN_NOT_OK(_cur_segment_group->load()); + RETURN_NOT_OK(flush()); _num_rows_written += alpha_rowset->num_rows(); } return OLAP_SUCCESS; } OLAPStatus AlphaRowsetWriter::flush() { if (_writer_state == WRITER_FLUSHED) { - LOG(WARNING) << "writer already flushed."; return OLAP_SUCCESS; } DCHECK(_writer_state == WRITER_INITED); - // column_data_writer finalize will call segment_group->set_empty() - OLAPStatus status = _column_data_writer->finalize(); + if (_need_column_data_writer) { + // column_data_writer finalize will call segment_group->set_empty() + RETURN_NOT_OK(_column_data_writer->finalize()); + } SAFE_DELETE(_column_data_writer); - _cur_segment_group->load(); + RETURN_NOT_OK(_cur_segment_group->load()); Review comment: I think load() should defer to build(). Transaction may be failed after you flush(), and load operation will be no-sense. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@doris.apache.org For additional commands, e-mail: dev-h...@doris.apache.org