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

yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new f87fad97e1 [Bug](storage) add lock on base tablet when create_tablet 
#21915
f87fad97e1 is described below

commit f87fad97e1c2eea615a7ced9eefce599e6483c8d
Author: Pxl <[email protected]>
AuthorDate: Wed Jul 19 00:47:19 2023 +0800

    [Bug](storage) add lock on base tablet when create_tablet #21915
---
 be/src/olap/tablet_manager.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/be/src/olap/tablet_manager.cpp b/be/src/olap/tablet_manager.cpp
index f37e1e1408..4f1c7ecf5e 100644
--- a/be/src/olap/tablet_manager.cpp
+++ b/be/src/olap/tablet_manager.cpp
@@ -29,6 +29,7 @@
 
 #include <algorithm>
 #include <list>
+#include <mutex>
 #include <ostream>
 
 // IWYU pragma: no_include <opentelemetry/common/threadlocal.h>
@@ -261,7 +262,12 @@ Status TabletManager::create_tablet(const 
TCreateTabletReq& request, std::vector
     // If the CreateTabletReq has base_tablet_id then it is a alter-tablet 
request
     if (request.__isset.base_tablet_id && request.base_tablet_id > 0) {
         is_schema_change = true;
-        base_tablet = _get_tablet_unlocked(request.base_tablet_id);
+        // if base_tablet_id's lock diffrent with new_tablet_id, we need lock 
it.
+        if ((_tablets_shards_mask & request.base_tablet_id) != 
(_tablets_shards_mask & tablet_id)) {
+            base_tablet = get_tablet(request.base_tablet_id);
+        } else {
+            base_tablet = _get_tablet_unlocked(request.base_tablet_id);
+        }
         if (base_tablet == nullptr) {
             
DorisMetrics::instance()->create_tablet_requests_failed->increment(1);
             return Status::Error<TABLE_CREATE_META_ERROR>(


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

Reply via email to