Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix](Variant) Schema should be updated when update_tmp_rowset in cloud mode #37557

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion be/src/cloud/cloud_meta_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,12 @@ Status CloudMetaMgr::update_tmp_rowset(const RowsetMeta& rs_meta) {
CreateRowsetResponse resp;
req.set_cloud_unique_id(config::cloud_unique_id);

RowsetMetaPB rs_meta_pb = rs_meta.get_rowset_pb(true);
// Variant schema maybe updated, so we need to update the schema as well.
// The updated rowset meta after `rowset->merge_rowset_meta` in `BaseTablet::update_delete_bitmap`
// will be lost in `update_tmp_rowset` if skip_schema.So in order to keep the latest schema we should keep schema in update_tmp_rowset
// for variant type
bool skip_schema = rs_meta.tablet_schema()->num_variant_columns() == 0;
RowsetMetaPB rs_meta_pb = rs_meta.get_rowset_pb(skip_schema);
doris_rowset_meta_to_cloud(req.mutable_rowset_meta(), std::move(rs_meta_pb));
Status st =
retry_rpc("update committed rowset", req, &resp, &MetaService_Stub::update_tmp_rowset);
Expand Down
7 changes: 5 additions & 2 deletions be/src/cloud/cloud_tablet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,11 @@ Result<std::unique_ptr<RowsetWriter>> CloudTablet::create_transient_rowset_write
RowsetWriterContext context;
context.rowset_state = PREPARED;
context.segments_overlap = OVERLAPPING;
context.tablet_schema = std::make_shared<TabletSchema>();
context.tablet_schema->copy_from(*(rowset.tablet_schema()));
// During a partial update, the extracted columns of a variant should not be included in the tablet schema.
// This is because the partial update for a variant needs to ignore the extracted columns.
// Otherwise, the schema types in different rowsets might be inconsistent. When performing a partial update,
// the complete variant is constructed by reading all the sub-columns of the variant.
context.tablet_schema = rowset.tablet_schema()->copy_without_variant_extracted_columns();
context.newest_write_timestamp = UnixSeconds();
context.tablet_id = table_id();
context.enable_segcompaction = false;
Expand Down
5 changes: 4 additions & 1 deletion cloud/src/meta-service/meta_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,10 @@ void MetaServiceImpl::update_tmp_rowset(::google::protobuf::RpcController* contr
msg = fmt::format("failed to check whether rowset exists, err={}", err);
return;
}

if (rowset_meta.has_variant_type_in_schema()) {
write_schema_dict(code, msg, instance_id, txn.get(), &rowset_meta);
if (code != MetaServiceCode::OK) return;
}
DCHECK_GT(rowset_meta.txn_expiration(), 0);
if (!rowset_meta.SerializeToString(&update_val)) {
code = MetaServiceCode::PROTOBUF_SERIALIZE_ERR;
Expand Down
4 changes: 1 addition & 3 deletions regression-test/suites/variant_p0/delete_update.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,5 @@ suite("regression_test_variant_delete_and_update", "variant_type"){

sql "sync"

if (!isCloudMode()) {
qt_sql """ select * from ${tableName} order by id;"""
}
qt_sql """ select * from ${tableName} order by id;"""
}
Loading