gavinchou commented on code in PR #56061:
URL: https://github.com/apache/doris/pull/56061#discussion_r2348265075


##########
cloud/src/meta-service/meta_service.cpp:
##########
@@ -731,6 +731,27 @@ void internal_create_tablet(const CreateTabletsRequest* 
request, MetaServiceCode
     std::string key;
     std::string val;
     meta_tablet_key(key_info, &key);
+
+    if (txn->get(key, &val) == TxnErrorCode::TXN_OK) {
+        doris::TabletMetaCloudPB exists_tablet_meta;
+        if (!exists_tablet_meta.ParseFromString(val)) {
+            code = MetaServiceCode::PROTOBUF_SERIALIZE_ERR;
+            msg = fmt::format("failed to serialize tablet meta, key={}", 
hex(key));
+            return;
+        }
+        if (exists_tablet_meta.tablet_id() == tablet_meta.tablet_id() &&
+            exists_tablet_meta.schema_version() == 
tablet_meta.schema_version()) {
+            // idempotent
+            code = MetaServiceCode::OK;
+            msg = "tablet already exists";
+            LOG(INFO) << "tablet already exists, "
+                      << " request tablet's tablet_id=" << 
tablet_meta.tablet_id()
+                      << " request tablet's schema_version=" << 
tablet_meta.schema_version()
+                      << " existed tablet's tablet_id=" << 
exists_tablet_meta.tablet_id()
+                      << " existed tablet's schema_version=" << 
exists_tablet_meta.schema_version();
+            return;
+        }

Review Comment:
   LOG warning or error, it is unexpected the existing value does not match 
with the request.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to