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

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


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new 6130427126a branch-3.0: [fix](mow) fix update delete bitmap lock not 
removed if schema change for empty tablet (#51780) (#52166)
6130427126a is described below

commit 6130427126a8f98bde9cf60c1ce138cc18d6d3dc
Author: meiyi <[email protected]>
AuthorDate: Tue Jun 24 20:02:39 2025 +0800

    branch-3.0: [fix](mow) fix update delete bitmap lock not removed if schema 
change for empty tablet (#51780) (#52166)
    
    pick https://github.com/apache/doris/pull/51780
---
 cloud/src/meta-service/meta_service_job.cpp | 30 ++++++++++++++---------------
 cloud/test/meta_service_job_test.cpp        | 22 +++++++++++++++++++++
 2 files changed, 37 insertions(+), 15 deletions(-)

diff --git a/cloud/src/meta-service/meta_service_job.cpp 
b/cloud/src/meta-service/meta_service_job.cpp
index 8d8da279b73..c71859decb7 100644
--- a/cloud/src/meta-service/meta_service_job.cpp
+++ b/cloud/src/meta-service/meta_service_job.cpp
@@ -1188,6 +1188,21 @@ void process_schema_change_job(MetaServiceCode& code, 
std::string& msg, std::str
     new_tablet_meta.SerializeToString(&new_tablet_val);
     txn->put(new_tablet_key, new_tablet_val);
 
+    // process mow table, check lock
+    if (new_tablet_meta.enable_unique_key_merge_on_write()) {
+        bool success = check_and_remove_delete_bitmap_update_lock(
+                code, msg, ss, txn, instance_id, new_table_id, 
SCHEMA_CHANGE_DELETE_BITMAP_LOCK_ID,
+                schema_change.delete_bitmap_lock_initiator());
+        if (!success) {
+            return;
+        }
+
+        std::string pending_key = meta_pending_delete_bitmap_key({instance_id, 
new_tablet_id});
+        txn->remove(pending_key);
+        LOG(INFO) << "xxx sc remove delete bitmap pending key, pending_key=" 
<< hex(pending_key)
+                  << " tablet_id=" << new_tablet_id << "job_id=" << 
schema_change.id();
+    }
+
     
//==========================================================================
     //                move rowsets [2-alter_version] to recycle
     
//==========================================================================
@@ -1317,21 +1332,6 @@ void process_schema_change_job(MetaServiceCode& code, 
std::string& msg, std::str
         return;
     }
 
-    // process mow table, check lock
-    if (new_tablet_meta.enable_unique_key_merge_on_write()) {
-        bool success = check_and_remove_delete_bitmap_update_lock(
-                code, msg, ss, txn, instance_id, new_table_id, 
SCHEMA_CHANGE_DELETE_BITMAP_LOCK_ID,
-                schema_change.delete_bitmap_lock_initiator());
-        if (!success) {
-            return;
-        }
-
-        std::string pending_key = meta_pending_delete_bitmap_key({instance_id, 
new_tablet_id});
-        txn->remove(pending_key);
-        LOG(INFO) << "xxx sc remove delete bitmap pending key, pending_key=" 
<< hex(pending_key)
-                  << " tablet_id=" << new_tablet_id << "job_id=" << 
schema_change.id();
-    }
-
     for (size_t i = 0; i < schema_change.txn_ids().size(); ++i) {
         auto tmp_rowset_key =
                 meta_rowset_tmp_key({instance_id, 
schema_change.txn_ids().at(i), new_tablet_id});
diff --git a/cloud/test/meta_service_job_test.cpp 
b/cloud/test/meta_service_job_test.cpp
index cf1b8cd7d58..521d01d101f 100644
--- a/cloud/test/meta_service_job_test.cpp
+++ b/cloud/test/meta_service_job_test.cpp
@@ -1881,6 +1881,28 @@ TEST(MetaServiceJobTest, SchemaChangeJobWithMoWTest) {
         remove_delete_bitmap_lock(meta_service.get(), table_id);
         res.Clear();
     }
+
+    // alter version < 2
+    {
+        int64_t new_tablet_id = 16;
+        ASSERT_NO_FATAL_FAILURE(create_tablet(meta_service.get(), table_id, 
index_id, partition_id,
+                                              new_tablet_id, true, true));
+        StartTabletJobResponse sc_res;
+        ASSERT_NO_FATAL_FAILURE(start_schema_change_job(meta_service.get(), 
table_id, index_id,
+                                                        partition_id, 
tablet_id, new_tablet_id,
+                                                        "job2", "be1", 
sc_res));
+        std::vector<doris::RowsetMetaCloudPB> output_rowsets;
+        auto res_code = get_delete_bitmap_lock(meta_service.get(), table_id, 
-2, 12345);
+        ASSERT_EQ(res_code, MetaServiceCode::OK);
+        FinishTabletJobResponse res;
+        finish_schema_change_job(meta_service.get(), tablet_id, new_tablet_id, 
"job2", "be1",
+                                 output_rowsets, res);
+        ASSERT_EQ(res.status().code(), MetaServiceCode::OK);
+        res_code = get_delete_bitmap_lock(meta_service.get(), table_id, 100, 
-1);
+        ASSERT_EQ(res_code, MetaServiceCode::OK);
+        remove_delete_bitmap_lock(meta_service.get(), table_id);
+        res.Clear();
+    }
 }
 
 TEST(MetaServiceJobTest, ConcurrentCompactionTest) {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to