This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.0 by this push:
new 47244fdbaee [fix](cloud) use snapshot read for table version to avoid
txn conflict (#64647) (#66068)
47244fdbaee is described below
commit 47244fdbaee6d8f72c20664cd7fbd9e3048f5c5b
Author: deardeng <[email protected]>
AuthorDate: Mon Jul 27 17:38:57 2026 +0800
[fix](cloud) use snapshot read for table version to avoid txn conflict
(#64647) (#66068)
pick from https://github.com/apache/doris/pull/64647
---
cloud/src/meta-service/meta_service_partition.cpp | 18 +++++++++++++++---
cloud/src/meta-service/meta_service_txn.cpp | 18 +++++++++++++++---
2 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/cloud/src/meta-service/meta_service_partition.cpp
b/cloud/src/meta-service/meta_service_partition.cpp
index c28abeadb0f..f4ed11c26c0 100644
--- a/cloud/src/meta-service/meta_service_partition.cpp
+++ b/cloud/src/meta-service/meta_service_partition.cpp
@@ -335,7 +335,11 @@ void
MetaServiceImpl::commit_index(::google::protobuf::RpcController* controller
int64_t table_id = request->table_id();
std::string ver_key = table_version_key({instance_id,
request->db_id(), table_id});
std::string ver_val;
- err = txn->get(ver_key, &ver_val);
+ // snapshot read: the returned table version is only a hint for
FE's version
+ // cache; the real increment is done by update_table_version() via
atomic_add.
+ // A non-snapshot read would add ver_key to the read-conflict set
and make
+ // concurrent commits on the same table conflict (KV_TXN_CONFLICT).
+ err = txn->get(ver_key, &ver_val, true);
int64_t table_version = 0;
if (err == TxnErrorCode::TXN_OK) {
if (!txn->decode_atomic_int(ver_val, &table_version)) {
@@ -845,7 +849,11 @@ void MetaServiceImpl::commit_partition_internal(const
PartitionRequest* request,
std::string ver_key =
table_version_key({instance_id, request->db_id(),
request->table_id()});
std::string ver_val;
- err = txn->get(ver_key, &ver_val);
+ // snapshot read: the returned table version is only a hint for FE's
version
+ // cache; the real increment is done by update_table_version() via
atomic_add.
+ // A non-snapshot read would add ver_key to the read-conflict set and
make
+ // concurrent commits on the same table conflict (KV_TXN_CONFLICT).
+ err = txn->get(ver_key, &ver_val, true);
int64_t table_version = 0;
if (err == TxnErrorCode::TXN_OK) {
if (!txn->decode_atomic_int(ver_val, &table_version)) {
@@ -1034,7 +1042,11 @@ void
MetaServiceImpl::drop_partition(::google::protobuf::RpcController* controll
std::string ver_key =
table_version_key({instance_id, request->db_id(),
request->table_id()});
std::string ver_val;
- err = txn->get(ver_key, &ver_val);
+ // snapshot read: the returned table version is only a hint for
FE's version
+ // cache; the real increment is done by update_table_version() via
atomic_add.
+ // A non-snapshot read would add ver_key to the read-conflict set
and make
+ // concurrent commits on the same table conflict (KV_TXN_CONFLICT).
+ err = txn->get(ver_key, &ver_val, true);
int64_t table_version = 0;
if (err == TxnErrorCode::TXN_OK) {
if (!txn->decode_atomic_int(ver_val, &table_version)) {
diff --git a/cloud/src/meta-service/meta_service_txn.cpp
b/cloud/src/meta-service/meta_service_txn.cpp
index 4694d0f14db..adcb18550ad 100644
--- a/cloud/src/meta-service/meta_service_txn.cpp
+++ b/cloud/src/meta-service/meta_service_txn.cpp
@@ -1791,7 +1791,11 @@ void MetaServiceImpl::commit_txn_immediately(
int64_t table_id = i.first;
std::string ver_key = table_version_key({instance_id, db_id,
table_id});
std::string ver_val;
- err = txn->get(ver_key, &ver_val);
+ // snapshot read: the returned table version is only a hint
for FE's version
+ // cache; the real increment is done by update_table_version()
via atomic_add.
+ // A non-snapshot read would add ver_key to the read-conflict
set and make
+ // concurrent commits on the same table conflict
(KV_TXN_CONFLICT).
+ err = txn->get(ver_key, &ver_val, true);
int64_t table_version = 0;
if (err == TxnErrorCode::TXN_OK) {
if (!txn->decode_atomic_int(ver_val, &table_version)) {
@@ -2480,7 +2484,11 @@ void MetaServiceImpl::commit_txn_eventually(
int64_t table_id = i.first;
std::string ver_key = table_version_key({instance_id, db_id,
table_id});
std::string ver_val;
- err = txn->get(ver_key, &ver_val);
+ // snapshot read: the returned table version is only a hint
for FE's version
+ // cache; the real increment is done by update_table_version()
via atomic_add.
+ // A non-snapshot read would add ver_key to the read-conflict
set and make
+ // concurrent commits on the same table conflict
(KV_TXN_CONFLICT).
+ err = txn->get(ver_key, &ver_val, true);
int64_t table_version = 0;
if (err == TxnErrorCode::TXN_OK) {
if (!txn->decode_atomic_int(ver_val, &table_version)) {
@@ -2969,7 +2977,11 @@ void MetaServiceImpl::commit_txn_with_sub_txn(const
CommitTxnRequest* request,
int64_t table_id = i.first;
std::string ver_key = table_version_key({instance_id, db_id,
table_id});
std::string ver_val;
- err = txn->get(ver_key, &ver_val);
+ // snapshot read: the returned table version is only a hint
for FE's version
+ // cache; the real increment is done by update_table_version()
via atomic_add.
+ // A non-snapshot read would add ver_key to the read-conflict
set and make
+ // concurrent commits on the same table conflict
(KV_TXN_CONFLICT).
+ err = txn->get(ver_key, &ver_val, true);
int64_t table_version = 0;
if (err == TxnErrorCode::TXN_OK) {
if (!txn->decode_atomic_int(ver_val, &table_version)) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]