This is an automated email from the ASF dual-hosted git repository. eldenmoon pushed a commit to branch branch-2.0-var in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0-var by this push: new f91ba2f0e4b [Bug](variant) make schema update in tablet atomic f91ba2f0e4b is described below commit f91ba2f0e4b1982e4ce0c21e41450219aa718b2f Author: eldenmoon <15605149...@163.com> AuthorDate: Tue Oct 10 14:27:10 2023 +0800 [Bug](variant) make schema update in tablet atomic --- be/src/olap/delta_writer.cpp | 6 +----- be/src/olap/tablet.cpp | 10 +++++++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/be/src/olap/delta_writer.cpp b/be/src/olap/delta_writer.cpp index 89707510043..23f44aa60e6 100644 --- a/be/src/olap/delta_writer.cpp +++ b/be/src/olap/delta_writer.cpp @@ -538,11 +538,7 @@ Status DeltaWriter::commit_txn(const PSlaveTabletNodes& slave_tablet_nodes, // _tabelt->tablet_schema: A(bigint), B(double) // => update_schema: A(bigint), B(double), C(int), D(int) RowsetWriterContext& rw_ctx = _rowset_writer->mutable_context(); - TabletSchemaSPtr update_schema = std::make_shared<TabletSchema>(); - vectorized::schema_util::get_least_common_schema( - {_tablet->tablet_schema(), rw_ctx.tablet_schema}, update_schema); - _tablet->update_by_least_common_schema(update_schema); - VLOG_DEBUG << "dump updated tablet schema: " << update_schema->dump_structure(); + _tablet->update_by_least_common_schema(rw_ctx.tablet_schema); } Status res = _storage_engine->txn_manager()->commit_txn(_req.partition_id, _tablet, _req.txn_id, diff --git a/be/src/olap/tablet.cpp b/be/src/olap/tablet.cpp index 6f6d6886a35..25148f662f0 100644 --- a/be/src/olap/tablet.cpp +++ b/be/src/olap/tablet.cpp @@ -2650,10 +2650,14 @@ void Tablet::update_max_version_schema(const TabletSchemaSPtr& tablet_schema) { } } -void Tablet::update_by_least_common_schema(const TabletSchemaSPtr& least_common_schema) { +void Tablet::update_by_least_common_schema(const TabletSchemaSPtr& update_schema) { std::lock_guard wrlock(_meta_lock); - CHECK(_max_version_schema->schema_version() >= least_common_schema->schema_version()); - _max_version_schema = least_common_schema; + auto final_schema = std::make_shared<TabletSchema>(); + CHECK(_max_version_schema->schema_version() >= update_schema->schema_version()); + vectorized::schema_util::get_least_common_schema( + {_max_version_schema, update_schema}, final_schema); + _max_version_schema = final_schema; + VLOG_DEBUG << "dump updated tablet schema: " << final_schema->dump_structure(); } // fetch value by row column --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org