gavinchou commented on code in PR #36786:
URL: https://github.com/apache/doris/pull/36786#discussion_r1666967015
##########
cloud/src/meta-service/meta_service_partition.cpp:
##########
@@ -614,4 +621,94 @@ void
MetaServiceImpl::drop_partition(::google::protobuf::RpcController* controll
}
}
+void check_create_table(std::string instance_id, std::shared_ptr<TxnKv> txn_kv,
+ const CheckKVRequest* request, CheckKVResponse*
response,
+ MetaServiceCode* code, std::string* msg,
+ check_create_table_type get_check_info) {
+ std::unique_ptr<Transaction> txn;
+ TxnErrorCode err = txn_kv->create_txn(&txn);
+ if (err != TxnErrorCode::TXN_OK) {
+ *code = cast_as<ErrCategory::READ>(err);
+ *msg = "failed to create txn";
+ return;
+ }
+ auto& [keys, hint, key_func] = get_check_info(request);
+ if (keys.empty()) {
+ *code = MetaServiceCode::INVALID_ARGUMENT;
+ *msg = "empty keys";
+ return;
+ }
+
+ for (auto id : keys) {
+ auto key = key_func(instance_id, id);
+ err = check_recycle_key_exist(txn.get(), key);
Review Comment:
is it possible that txn may exceed 5s duration?
we can separate it to several txn for rubustness.
##########
cloud/src/meta-service/meta_service_partition.cpp:
##########
@@ -614,4 +621,94 @@ void
MetaServiceImpl::drop_partition(::google::protobuf::RpcController* controll
}
}
+void check_create_table(std::string instance_id, std::shared_ptr<TxnKv> txn_kv,
+ const CheckKVRequest* request, CheckKVResponse*
response,
+ MetaServiceCode* code, std::string* msg,
+ check_create_table_type get_check_info) {
+ std::unique_ptr<Transaction> txn;
+ TxnErrorCode err = txn_kv->create_txn(&txn);
+ if (err != TxnErrorCode::TXN_OK) {
+ *code = cast_as<ErrCategory::READ>(err);
+ *msg = "failed to create txn";
+ return;
+ }
+ auto& [keys, hint, key_func] = get_check_info(request);
+ if (keys.empty()) {
+ *code = MetaServiceCode::INVALID_ARGUMENT;
+ *msg = "empty keys";
+ return;
+ }
+
+ for (auto id : keys) {
+ auto key = key_func(instance_id, id);
+ err = check_recycle_key_exist(txn.get(), key);
+ if (err == TxnErrorCode::TXN_KEY_NOT_FOUND) {
+ continue;
+ } else if (err == TxnErrorCode::TXN_OK) {
+ // find not match, prepare commit
+ *code = MetaServiceCode::ALREADY_EXISTED;
Review Comment:
this should be an internal error?
##########
fe/fe-core/src/main/java/org/apache/doris/cloud/datasource/CloudInternalCatalog.java:
##########
@@ -549,6 +562,80 @@ public void commitMaterializedIndex(long dbId, long
tableId, List<Long> indexIds
}
}
+ private void checkPartition(long dbId, long tableId, List<Long>
partitionIds)
+ throws DdlException {
+ Cloud.CheckKeyInfos.Builder checkKeyInfosBuilder =
Cloud.CheckKeyInfos.newBuilder();
+ checkKeyInfosBuilder.addAllPartitionIds(partitionIds);
+ // for ms log
+ checkKeyInfosBuilder.addDbIds(dbId);
+ checkKeyInfosBuilder.addTableIds(tableId);
+
+ Cloud.CheckKVRequest.Builder checkKvRequestBuilder =
Cloud.CheckKVRequest.newBuilder();
+ checkKvRequestBuilder.setCloudUniqueId(Config.cloud_unique_id);
+ checkKvRequestBuilder.setCheckKeys(checkKeyInfosBuilder.build());
+
checkKvRequestBuilder.setOp(Cloud.CheckKVRequest.Operation.CREATE_PARTITION_AFTER_FE_COMMIT);
+ final Cloud.CheckKVRequest checkKVRequest =
checkKvRequestBuilder.build();
+
+ Cloud.CheckKVResponse response = null;
+ int tryTimes = 0;
+ while (tryTimes++ < Config.metaServiceRpcRetryTimes()) {
+ try {
+ response =
MetaServiceProxy.getInstance().checkKv(checkKVRequest);
+ if (response.getStatus().getCode() !=
Cloud.MetaServiceCode.KV_TXN_CONFLICT) {
Review Comment:
is `txn_confilict` already handled on the ms-server side? @w41ter ?
--
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]