[Fix](Variant) Initialize original_tablet_schema in _expand_variant_to_subcolumns to address potential nullptr issue (#32184) (#32678)

This commit is contained in:
lihangyu
2024-03-22 18:02:58 +08:00
committed by GitHub
parent 0d0f787d3e
commit fdc19b4892
5 changed files with 8 additions and 5 deletions

View File

@ -112,7 +112,6 @@ Status DeltaWriterV2::init() {
context.rowset_state = PREPARED;
context.segments_overlap = OVERLAPPING;
context.tablet_schema = _tablet_schema;
context.original_tablet_schema = _tablet_schema;
context.newest_write_timestamp = UnixSeconds();
context.tablet = nullptr;
context.write_type = DataWriteType::TYPE_DIRECT;

View File

@ -229,7 +229,6 @@ Status PushHandler::_convert_v2(TabletSharedPtr cur_tablet, RowsetSharedPtr* cur
context.rowset_state = PREPARED;
context.segments_overlap = OVERLAP_UNKNOWN;
context.tablet_schema = tablet_schema;
context.original_tablet_schema = tablet_schema;
context.newest_write_timestamp = UnixSeconds();
auto rowset_writer = DORIS_TRY(cur_tablet->create_rowset_writer(context, false));
_pending_rs_guard =

View File

@ -91,6 +91,14 @@ Status SegmentFlusher::_expand_variant_to_subcolumns(vectorized::Block& block,
return Status::OK();
}
{
std::lock_guard<std::mutex> lock(*(_context->schema_lock));
// save original tablet schema, _context->tablet_schema maybe modified
if (_context->original_tablet_schema == nullptr) {
_context->original_tablet_schema = _context->tablet_schema;
}
}
std::vector<int> variant_column_pos;
if (_context->partial_update_info && _context->partial_update_info->is_partial_update) {
// check columns that used to do partial updates should not include variant

View File

@ -199,7 +199,6 @@ Status RowsetBuilder::init() {
context.rowset_state = PREPARED;
context.segments_overlap = OVERLAPPING;
context.tablet_schema = _tablet_schema;
context.original_tablet_schema = _tablet_schema;
context.newest_write_timestamp = UnixSeconds();
context.tablet_id = _tablet->tablet_id();
context.tablet = _tablet;

View File

@ -621,7 +621,6 @@ Result<std::pair<RowsetSharedPtr, PendingRowsetGuard>> VSchemaChangeWithSorting:
context.rowset_state = VISIBLE;
context.segments_overlap = segments_overlap;
context.tablet_schema = new_tablet_schema;
context.original_tablet_schema = new_tablet_schema;
context.newest_write_timestamp = newest_write_timestamp;
context.write_type = DataWriteType::TYPE_SCHEMA_CHANGE;
std::unique_ptr<RowsetWriter> rowset_writer;
@ -1082,7 +1081,6 @@ Status SchemaChangeHandler::_convert_historical_rowsets(const SchemaChangeParams
context.rowset_state = VISIBLE;
context.segments_overlap = rs_reader->rowset()->rowset_meta()->segments_overlap();
context.tablet_schema = sc_params.new_tablet_schema;
context.original_tablet_schema = sc_params.new_tablet_schema;
context.newest_write_timestamp = rs_reader->newest_write_timestamp();
context.fs = rs_reader->rowset()->rowset_meta()->fs();
context.write_type = DataWriteType::TYPE_SCHEMA_CHANGE;