Skip to content

Commit 3a99d28

Browse files
committed
*: disable async commit
Signed-off-by: Chao Wang <cclcwangchao@hotmail.com>
1 parent 70d01fd commit 3a99d28

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

.github/workflows/integration.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Integration Test
22

33
on:
44
push:
5-
branches: [ master, tidb-8.5 ]
5+
branches: [ master, tidb-8.5, "feature/*" ]
66
pull_request:
7-
branches: [ master, tidb-8.5 ]
7+
branches: [ master, tidb-8.5, "feature/*" ]
88

99
jobs:
1010

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Unit Test
22

33
on:
44
push:
5-
branches: [master, tidb-8.5]
5+
branches: [master, tidb-8.5, "feature/*"]
66
pull_request:
7-
branches: [master, tidb-8.5]
7+
branches: [master, tidb-8.5, "feature/*"]
88

99
jobs:
1010
test:

txnkv/transaction/2pc.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,24 @@ var (
9292
CommitMaxBackoff = uint64(40000)
9393
)
9494

95+
// supportActiveActiveCommit indicates whether the active-active commit protocol is supported.
96+
// If it is true (by default), we should not use async-commit or 1PC to ensure the commit timestamp
97+
// should follow the `tso-unique-index` constraint.
98+
var supportActiveActiveCommit = atomicutil.NewBool(true)
99+
100+
// DisableActiveActiveCommitSupportForTest disables the active-active commit for test,
101+
// which will make async-commit and 1PC work without the `tso-unique-index` constraint.
102+
// It should only be used in test.
103+
func DisableActiveActiveCommitSupportForTest() func() {
104+
if !supportActiveActiveCommit.CompareAndSwap(true, false) {
105+
return func() {}
106+
}
107+
108+
return func() {
109+
supportActiveActiveCommit.Store(true)
110+
}
111+
}
112+
95113
type kvstore interface {
96114
// GetRegionCache gets the RegionCache.
97115
GetRegionCache() *locate.RegionCache
@@ -1504,6 +1522,10 @@ func sendTxnHeartBeat(
15041522

15051523
// checkAsyncCommit checks if async commit protocol is available for current transaction commit, true is returned if possible.
15061524
func (c *twoPhaseCommitter) checkAsyncCommit() bool {
1525+
if supportActiveActiveCommit.Load() {
1526+
return false
1527+
}
1528+
15071529
// Disable async commit in local transactions
15081530
if c.txn.GetScope() != oracle.GlobalTxnScope {
15091531
return false
@@ -1535,6 +1557,10 @@ func (c *twoPhaseCommitter) checkAsyncCommit() bool {
15351557

15361558
// checkOnePC checks if 1PC protocol is available for current transaction.
15371559
func (c *twoPhaseCommitter) checkOnePC() bool {
1560+
if supportActiveActiveCommit.Load() {
1561+
return false
1562+
}
1563+
15381564
// Disable 1PC in local transactions
15391565
if c.txn.GetScope() != oracle.GlobalTxnScope {
15401566
return false

0 commit comments

Comments
 (0)