You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by da...@apache.org on 2024/04/13 12:52:31 UTC

(doris) 11/13: [fix](merge-on-write) schema change may cause mow duplicate key (#33536)

This is an automated email from the ASF dual-hosted git repository.

dataroaring pushed a commit to branch branch-4.0-preview
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 5611fedba9176bf80dc83b802274f7112db9fcdd
Author: zhannngchen <48...@users.noreply.github.com>
AuthorDate: Sat Apr 13 10:41:30 2024 +0800

    [fix](merge-on-write) schema change may cause mow duplicate key (#33536)
---
 be/src/olap/schema_change.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/be/src/olap/schema_change.cpp b/be/src/olap/schema_change.cpp
index fb9137d4c84..13182467591 100644
--- a/be/src/olap/schema_change.cpp
+++ b/be/src/olap/schema_change.cpp
@@ -969,6 +969,8 @@ Status SchemaChangeJob::_do_process_alter_tablet(const TAlterTabletReqV2& reques
             break;
         }
 
+        DCHECK_GE(real_alter_version, request.alter_version);
+
         if (_new_tablet->keys_type() == UNIQUE_KEYS &&
             _new_tablet->enable_unique_key_merge_on_write()) {
             res = _calc_delete_bitmap_for_mow_table(real_alter_version);
@@ -1086,6 +1088,7 @@ Status SchemaChangeJob::_convert_historical_rowsets(const SchemaChangeParams& sc
     auto sc_procedure = _get_sc_procedure(changer, sc_sorting, sc_directly);
 
     // c.Convert historical data
+    bool have_failure_rowset = false;
     for (const auto& rs_reader : sc_params.ref_rowset_readers) {
         // set status for monitor
         // As long as there is a new_table as running, ref table is set as running
@@ -1131,6 +1134,7 @@ Status SchemaChangeJob::_convert_historical_rowsets(const SchemaChangeParams& sc
                          << "tablet=" << _new_tablet->tablet_id() << ", version='"
                          << rs_reader->version().first << "-" << rs_reader->version().second;
             _local_storage_engine.add_unused_rowset(new_rowset);
+            have_failure_rowset = true;
             res = Status::OK();
         } else if (!res) {
             LOG(WARNING) << "failed to register new version. "
@@ -1144,7 +1148,9 @@ Status SchemaChangeJob::_convert_historical_rowsets(const SchemaChangeParams& sc
                         << ", version=" << rs_reader->version().first << "-"
                         << rs_reader->version().second;
         }
-        *real_alter_version = rs_reader->version().second;
+        if (!have_failure_rowset) {
+            *real_alter_version = rs_reader->version().second;
+        }
 
         VLOG_TRACE << "succeed to convert a history version."
                    << " version=" << rs_reader->version().first << "-"


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org