This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new ec174c1e543 branch-3.0: [chore](cloud) Optimize fuzzy test for txn
lazy commit #54382 (#54574)
ec174c1e543 is described below
commit ec174c1e54397f7777f4ee3396c0750363826294
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Aug 12 10:05:56 2025 +0800
branch-3.0: [chore](cloud) Optimize fuzzy test for txn lazy commit #54382
(#54574)
Cherry-picked from #54382
Co-authored-by: Gavin Chou <[email protected]>
---
cloud/src/common/config.h | 5 ++++-
cloud/src/meta-service/meta_service_txn.cpp | 14 +++++---------
cloud/test/txn_lazy_commit_test.cpp | 17 +++--------------
regression-test/pipeline/cloud_p0/conf/ms_custom.conf | 2 +-
regression-test/pipeline/cloud_p1/conf/ms_custom.conf | 2 +-
5 files changed, 14 insertions(+), 26 deletions(-)
diff --git a/cloud/src/common/config.h b/cloud/src/common/config.h
index b767d696034..c52f4100f3c 100644
--- a/cloud/src/common/config.h
+++ b/cloud/src/common/config.h
@@ -281,7 +281,10 @@ CONF_Int32(txn_lazy_max_rowsets_per_batch, "1000");
// max TabletIndexPB num for batch get
CONF_Int32(max_tablet_index_num_per_batch, "1000");
-CONF_Bool(enable_cloud_txn_lazy_commit_fuzzy_test, "false");
+// the possibility to use a lazy commit for a doris txn, ranges from 0 to 100,
+// usually for testing
+// 0 for never, 100 for always
+CONF_mInt32(cloud_txn_lazy_commit_fuzzy_possibility, "0");
CONF_Bool(enable_check_instance_id, "true");
diff --git a/cloud/src/meta-service/meta_service_txn.cpp
b/cloud/src/meta-service/meta_service_txn.cpp
index 28e262226ed..b2326e395c8 100644
--- a/cloud/src/meta-service/meta_service_txn.cpp
+++ b/cloud/src/meta-service/meta_service_txn.cpp
@@ -2585,15 +2585,10 @@ void commit_txn_with_sub_txn(const CommitTxnRequest*
request, CommitTxnResponse*
response->mutable_txn_info()->CopyFrom(txn_info);
} // end commit_txn_with_sub_txn
-static bool fuzzy_random() {
- return std::chrono::steady_clock::now().time_since_epoch().count() & 0x01;
-}
-
static bool force_txn_lazy_commit() {
- if (config::enable_cloud_txn_lazy_commit_fuzzy_test) [[unlikely]] {
- return fuzzy_random();
- }
- return false;
+ static std::mt19937 rng(20250806 /* seed */);
+ static std::uniform_int_distribution<int> dist(1, 100);
+ return dist(rng) <= config::cloud_txn_lazy_commit_fuzzy_possibility;
}
void MetaServiceImpl::commit_txn(::google::protobuf::RpcController* controller,
@@ -2638,7 +2633,8 @@ void
MetaServiceImpl::commit_txn(::google::protobuf::RpcController* controller,
while ((!enable_txn_lazy_commit_feature ||
(tmp_rowsets_meta.size() <=
config::txn_lazy_commit_rowsets_thresold))) {
if (force_txn_lazy_commit()) {
- LOG(INFO) << "fuzzy test force_txn_lazy_commit, txn_id=" << txn_id;
+ LOG(INFO) << "fuzzy test force_txn_lazy_commit, txn_id=" << txn_id
+ << " force_posibility=" <<
config::cloud_txn_lazy_commit_fuzzy_possibility;
break;
}
diff --git a/cloud/test/txn_lazy_commit_test.cpp
b/cloud/test/txn_lazy_commit_test.cpp
index d2bf82435d8..e07485d8c0d 100644
--- a/cloud/test/txn_lazy_commit_test.cpp
+++ b/cloud/test/txn_lazy_commit_test.cpp
@@ -1909,21 +1909,10 @@ TEST(TxnLazyCommitTest, RowsetMetaSizeExceedTest) {
ASSERT_EQ(res.status().code(), MetaServiceCode::PROTOBUF_PARSE_ERR);
}
}
-TEST(TxnLazyCommitTest, FuzzyRandom) {
- int counter = 0;
- for (size_t i = 0; i < 100000; i++) {
- if (fuzzy_random()) {
- counter++;
- }
- }
- LOG(INFO) << "fuzzy_random counter: " << counter;
- ASSERT_GT(counter, 30000);
- ASSERT_LT(counter, 70000);
-}
TEST(TxnLazyCommitTest, ForceTxnLazyCommit) {
int counter = 0;
- config::enable_cloud_txn_lazy_commit_fuzzy_test = false;
+ config::cloud_txn_lazy_commit_fuzzy_possibility = 0;
for (size_t i = 0; i < 100000; i++) {
if (force_txn_lazy_commit()) {
counter++;
@@ -1932,7 +1921,7 @@ TEST(TxnLazyCommitTest, ForceTxnLazyCommit) {
LOG(INFO) << "force_txn_lazy_commit counter: " << counter;
ASSERT_EQ(counter, 0);
- config::enable_cloud_txn_lazy_commit_fuzzy_test = true;
+ config::cloud_txn_lazy_commit_fuzzy_possibility = 50;
counter = 0;
for (size_t i = 0; i < 100000; i++) {
if (force_txn_lazy_commit()) {
@@ -1942,7 +1931,7 @@ TEST(TxnLazyCommitTest, ForceTxnLazyCommit) {
LOG(INFO) << "force_txn_lazy_commit counter: " << counter;
ASSERT_GT(counter, 30000);
ASSERT_LT(counter, 70000);
- config::enable_cloud_txn_lazy_commit_fuzzy_test = false;
+ config::cloud_txn_lazy_commit_fuzzy_possibility = 0;
}
TEST(TxnLazyCommitTest, RecycleTmpRowsetsCase1) {
diff --git a/regression-test/pipeline/cloud_p0/conf/ms_custom.conf
b/regression-test/pipeline/cloud_p0/conf/ms_custom.conf
index 39b9d6c348d..53873da71ed 100644
--- a/regression-test/pipeline/cloud_p0/conf/ms_custom.conf
+++ b/regression-test/pipeline/cloud_p0/conf/ms_custom.conf
@@ -1,3 +1,3 @@
# below lines will be appended to the default doris_cloud.conf when deploying
meta service
meta_schema_value_version = 1
-enable_cloud_txn_lazy_commit_fuzzy_test = true
+cloud_txn_lazy_commit_fuzzy_possibility = 50
diff --git a/regression-test/pipeline/cloud_p1/conf/ms_custom.conf
b/regression-test/pipeline/cloud_p1/conf/ms_custom.conf
index 8a2f8734fb4..65080d400d2 100644
--- a/regression-test/pipeline/cloud_p1/conf/ms_custom.conf
+++ b/regression-test/pipeline/cloud_p1/conf/ms_custom.conf
@@ -1,2 +1,2 @@
# below lines will be appended to the default doris_cloud.conf when deploying
meta service
-enable_cloud_txn_lazy_commit_fuzzy_test = true
+cloud_txn_lazy_commit_fuzzy_possibility = 50
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]