This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.1 by this push:
new 9883fcfd9a3 branch-4.1: [fix](cloud) use snapshot read for table
version to avoid txn conflict #64647 (#64999)
9883fcfd9a3 is described below
commit 9883fcfd9a3161c827a2c5f91d87b90d3ce0827a
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Jun 30 19:42:52 2026 +0800
branch-4.1: [fix](cloud) use snapshot read for table version to avoid txn
conflict #64647 (#64999)
Cherry-picked from #64647
Co-authored-by: deardeng <[email protected]>
---
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 5f66ca4216e..8936ba32e96 100644
--- a/cloud/src/meta-service/meta_service_partition.cpp
+++ b/cloud/src/meta-service/meta_service_partition.cpp
@@ -342,7 +342,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)) {
@@ -856,7 +860,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)) {
@@ -1045,7 +1053,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 18986625b7d..5c35958b1f0 100644
--- a/cloud/src/meta-service/meta_service_txn.cpp
+++ b/cloud/src/meta-service/meta_service_txn.cpp
@@ -1853,7 +1853,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)) {
@@ -2556,7 +2560,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)) {
@@ -3050,7 +3058,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]