Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Integration Test

on:
push:
branches: [ master, tidb-8.5 ]
branches: [ master, tidb-8.5, "feature/*" ]
pull_request:
branches: [ master, tidb-8.5 ]
branches: [ master, tidb-8.5, "feature/*" ]

jobs:

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Unit Test

on:
push:
branches: [master, tidb-8.5]
branches: [master, tidb-8.5, "feature/*"]
pull_request:
branches: [master, tidb-8.5]
branches: [master, tidb-8.5, "feature/*"]

jobs:
test:
Expand Down
2 changes: 1 addition & 1 deletion examples/gcworker/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a // indirect
github.com/tikv/pd/client v0.0.0-20260130064140-38b7a823c76d // indirect
github.com/tikv/pd/client v0.0.0-20251219084741-029eb6e7d5d0 // indirect
github.com/twmb/murmur3 v1.1.3 // indirect
go.etcd.io/etcd/api/v3 v3.5.10 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect
Expand Down
2 changes: 1 addition & 1 deletion examples/rawkv/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a // indirect
github.com/tikv/pd/client v0.0.0-20260130064140-38b7a823c76d // indirect
github.com/tikv/pd/client v0.0.0-20251219084741-029eb6e7d5d0 // indirect
github.com/twmb/murmur3 v1.1.3 // indirect
go.etcd.io/etcd/api/v3 v3.5.10 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect
Expand Down
2 changes: 1 addition & 1 deletion examples/txnkv/1pc_txn/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a // indirect
github.com/tikv/pd/client v0.0.0-20260130064140-38b7a823c76d // indirect
github.com/tikv/pd/client v0.0.0-20251219084741-029eb6e7d5d0 // indirect
github.com/twmb/murmur3 v1.1.3 // indirect
go.etcd.io/etcd/api/v3 v3.5.10 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect
Expand Down
2 changes: 1 addition & 1 deletion examples/txnkv/async_commit/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a // indirect
github.com/tikv/pd/client v0.0.0-20260130064140-38b7a823c76d // indirect
github.com/tikv/pd/client v0.0.0-20251219084741-029eb6e7d5d0 // indirect
github.com/twmb/murmur3 v1.1.3 // indirect
go.etcd.io/etcd/api/v3 v3.5.10 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect
Expand Down
2 changes: 1 addition & 1 deletion examples/txnkv/delete_range/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a // indirect
github.com/tikv/pd/client v0.0.0-20260130064140-38b7a823c76d // indirect
github.com/tikv/pd/client v0.0.0-20251219084741-029eb6e7d5d0 // indirect
github.com/twmb/murmur3 v1.1.3 // indirect
go.etcd.io/etcd/api/v3 v3.5.10 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect
Expand Down
2 changes: 1 addition & 1 deletion examples/txnkv/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a // indirect
github.com/tikv/pd/client v0.0.0-20260130064140-38b7a823c76d // indirect
github.com/tikv/pd/client v0.0.0-20251219084741-029eb6e7d5d0 // indirect
github.com/twmb/murmur3 v1.1.3 // indirect
go.etcd.io/etcd/api/v3 v3.5.10 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect
Expand Down
2 changes: 1 addition & 1 deletion examples/txnkv/pessimistic_txn/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a // indirect
github.com/tikv/pd/client v0.0.0-20260130064140-38b7a823c76d // indirect
github.com/tikv/pd/client v0.0.0-20251219084741-029eb6e7d5d0 // indirect
github.com/twmb/murmur3 v1.1.3 // indirect
go.etcd.io/etcd/api/v3 v3.5.10 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect
Expand Down
2 changes: 1 addition & 1 deletion examples/txnkv/unsafedestoryrange/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a // indirect
github.com/tikv/pd/client v0.0.0-20260130064140-38b7a823c76d // indirect
github.com/tikv/pd/client v0.0.0-20251219084741-029eb6e7d5d0 // indirect
github.com/twmb/murmur3 v1.1.3 // indirect
go.etcd.io/etcd/api/v3 v3.5.10 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/prometheus/client_model v0.6.1
github.com/stretchr/testify v1.9.0
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a
github.com/tikv/pd/client v0.0.0-20260130064140-38b7a823c76d
github.com/tikv/pd/client v0.0.0-20251219084741-029eb6e7d5d0
github.com/twmb/murmur3 v1.1.3
go.etcd.io/etcd/api/v3 v3.5.10
go.etcd.io/etcd/client/v3 v3.5.10
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a h1:J/YdBZ46WKpXsxsW93SG+q0F8KI+yFrcIDT4c/RNoc4=
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a/go.mod h1:h4xBhSNtOeEosLJ4P7JyKXX7Cabg7AVkWCK5gV2vOrM=
github.com/tikv/pd/client v0.0.0-20260130064140-38b7a823c76d h1:FeP05UtWzZsXYTsxpgHZNxiYiw0FoxFGY/ioOzOqrPA=
github.com/tikv/pd/client v0.0.0-20260130064140-38b7a823c76d/go.mod h1:X3T+jK+4bLbDKgupmzvVXuySnCNV4Lfdm/bL8TAw3ik=
github.com/tikv/pd/client v0.0.0-20251219084741-029eb6e7d5d0 h1:fguMZ4sSn/oLbUt+zDoNPd6+OE3Li4Rop2/3vFhu8lM=
github.com/tikv/pd/client v0.0.0-20251219084741-029eb6e7d5d0/go.mod h1:X3T+jK+4bLbDKgupmzvVXuySnCNV4Lfdm/bL8TAw3ik=
github.com/twmb/murmur3 v1.1.3 h1:D83U0XYKcHRYwYIpBKf3Pks91Z0Byda/9SJ8B6EMRcA=
github.com/twmb/murmur3 v1.1.3/go.mod h1:Qq/R7NUyOfr65zD+6Q5IHKsJLwP7exErjN6lyyq3OSQ=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
5 changes: 4 additions & 1 deletion integration_tests/2pc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ func (s *testCommitterSuite) SetupTest() {
s.cluster = cluster
pdCli := tikv.NewCodecPDClient(tikv.ModeTxn, pdClient)
spkv := tikv.NewMockSafePointKV()
store, err := tikv.NewKVStore("mocktikv-store", pdCli, spkv, client)
store, err := tikv.NewKVStore("mocktikv-store", pdCli, spkv, client,
// To make sure some exists tests with async-commit or 1pc commit pass
tikv.WithDisableActiveActiveCommitSupportForTest(),
)
store.EnableTxnLocalLatches(8096)
s.Require().Nil(err)
s.store = tikv.StoreProbe{KVStore: store}
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/stretchr/testify v1.10.0
github.com/tidwall/gjson v1.14.1
github.com/tikv/client-go/v2 v2.0.8-0.20260112052152-1d3c5ec76bf8
github.com/tikv/pd/client v0.0.0-20260130064140-38b7a823c76d
github.com/tikv/pd/client v0.0.0-20251219084741-029eb6e7d5d0
go.uber.org/goleak v1.3.0
)

Expand Down
4 changes: 2 additions & 2 deletions integration_tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,8 @@ github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tikv/pd/client v0.0.0-20260130064140-38b7a823c76d h1:FeP05UtWzZsXYTsxpgHZNxiYiw0FoxFGY/ioOzOqrPA=
github.com/tikv/pd/client v0.0.0-20260130064140-38b7a823c76d/go.mod h1:X3T+jK+4bLbDKgupmzvVXuySnCNV4Lfdm/bL8TAw3ik=
github.com/tikv/pd/client v0.0.0-20251219084741-029eb6e7d5d0 h1:fguMZ4sSn/oLbUt+zDoNPd6+OE3Li4Rop2/3vFhu8lM=
github.com/tikv/pd/client v0.0.0-20251219084741-029eb6e7d5d0/go.mod h1:X3T+jK+4bLbDKgupmzvVXuySnCNV4Lfdm/bL8TAw3ik=
github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs=
github.com/tklauser/go-sysconf v0.3.15 h1:VE89k0criAymJ/Os65CSn1IXaol+1wrsFHEB8Ol49K4=
github.com/tklauser/go-sysconf v0.3.15/go.mod h1:Dmjwr6tYFIseJw7a3dRLJfsHAMXZ3nEnL/aZY+0IuI4=
Expand Down
51 changes: 51 additions & 0 deletions integration_tests/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ import (

"github.com/pingcap/failpoint"
"github.com/pingcap/kvproto/pkg/kvrpcpb"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"github.com/tikv/client-go/v2/oracle"
"github.com/tikv/client-go/v2/oracle/oracles"
"github.com/tikv/client-go/v2/testutils"
"github.com/tikv/client-go/v2/tikv"
"github.com/tikv/client-go/v2/tikvrpc"
"github.com/tikv/client-go/v2/txnkv"
"github.com/tikv/client-go/v2/txnkv/transaction"
"github.com/tikv/client-go/v2/util"
)

func TestStore(t *testing.T) {
Expand Down Expand Up @@ -192,3 +196,50 @@ func (s *testStoreSuite) TestFailBusyServerKV() {
s.Nil(err)
s.Equal(val.Value, []byte("value"))
}

func TestEnableActiveActiveCommitByDefault(t *testing.T) {
re := require.New(t)

client, cluster, pdClient, err := testutils.NewMockTiKV("", nil)
re.NoError(err)
testutils.BootstrapWithSingleStore(cluster)

pdCli := tikv.NewCodecPDClient(tikv.ModeTxn, pdClient)
spkv := tikv.NewMockSafePointKV()
store, err := tikv.NewKVStore("default-active-active-commit-store", pdCli, spkv, client)
re.NoError(err)
defer func() {
re.NoError(store.Close())
}()

re.False(store.IsActiveActiveCommitSupportDisabled())

txn, err := store.Begin()
re.NoError(err)
re.NoError(txn.Set([]byte("aa"), []byte("v1")))
re.NoError(txn.Set([]byte("ab"), []byte("v2")))
txn.SetEnableAsyncCommit(true)
txn.SetEnable1PC(true)

txnProbe := transaction.TxnProbe{KVTxn: txn}
committer, err := txnProbe.NewCommitter(1)
re.NoError(err)
re.False(committer.CheckAsyncCommit())
re.False(committer.CheckOnePC())

ctx := context.WithValue(context.Background(), util.SessionID, uint64(1))
re.NoError(txn.Commit(ctx))
re.False(txnProbe.IsAsyncCommit())
re.False(txnProbe.GetCommitter().IsOnePC())
re.Zero(txnProbe.GetCommitter().GetOnePCCommitTS())

verifyTxn, err := store.Begin()
re.NoError(err)
value, err := verifyTxn.Get(context.Background(), []byte("aa"))
re.NoError(err)
re.Equal([]byte("v1"), value.Value)
value, err = verifyTxn.Get(context.Background(), []byte("ab"))
re.NoError(err)
re.Equal([]byte("v2"), value.Value)
re.NoError(verifyTxn.Rollback())
}
2 changes: 2 additions & 0 deletions integration_tests/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ func newTiKVStore(t *testing.T) *tikv.KVStore {
pdClient,
spKV,
tikv.NewRPCClient(opt),
// To make sure some exists tests with async-commit or 1pc commit pass
tikv.WithDisableActiveActiveCommitSupportForTest(),
)
re.Nil(err)
err = clearStorage(store)
Expand Down
12 changes: 12 additions & 0 deletions tikv/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ type KVStore struct {

mock bool

// disableActiveActiveCommitSupport indicates whether to disable active-active commit support.
// The default value is false, which disables the async-commit and 1PC to ensure the commit timestamp should
// always follow the constraint by PD settings `tso-unique-index`.
disableActiveActiveCommitSupport bool

kv SafePointKV
safePoint uint64
spTime time.Time
Expand Down Expand Up @@ -882,6 +887,13 @@ func (s *KVStore) updateGlobalTxnScopeTSFromPD(ctx context.Context) bool {
return false
}

// IsActiveActiveCommitSupportDisabled indicates whether to disable active-active commit support.
// The default value is false, which disables the async-commit and 1PC to ensure the commit timestamp should
// always follow the constraint by PD settings `tso-unique-index`.
func (s *KVStore) IsActiveActiveCommitSupportDisabled() bool {
return s.disableActiveActiveCommitSupport
}

func isValidSafeTS(ts uint64) bool {
return ts != 0 && ts != math.MaxUint64
}
Expand Down
19 changes: 19 additions & 0 deletions tikv/test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ func (c *CodecClient) SendRequestAsync(ctx context.Context, addr string, req *ti
c.Client.SendRequestAsync(ctx, addr, req, cb)
}

func disableActiveActiveCommitSupport(opt ...Option) []Option {
newOpts := make([]Option, 0, len(opt)+1)
newOpts = append(newOpts, WithDisableActiveActiveCommitSupportForTest())
newOpts = append(newOpts, opt...)
return newOpts
}

// NewTestTiKVStore creates a test store with Option
func NewTestTiKVStore(client Client, pdClient pd.Client, clientHijack func(Client) Client, pdClientHijack func(pd.Client) pd.Client, txnLocalLatches uint, opt ...Option) (*KVStore, error) {
codec := apicodec.NewCodecV1(apicodec.ModeTxn)
Expand All @@ -104,6 +111,8 @@ func NewTestTiKVStore(client Client, pdClient pd.Client, clientHijack func(Clien
// Make sure the uuid is unique.
uid := uuid.New().String()
spkv := NewMockSafePointKV()
// To make sure some exists tests with async-commit or 1pc commit pass
opt = disableActiveActiveCommitSupport(opt...)
tikvStore, err := NewKVStore(uid, pdCli, spkv, client, opt...)

if txnLocalLatches > 0 {
Expand Down Expand Up @@ -144,6 +153,8 @@ func NewTestKeyspaceTiKVStore(client Client, pdClient pd.Client, clientHijack fu

keyspaceIdStr := strconv.FormatUint(uint64(keyspaceMeta.Id), 10)
spkv := NewMockSafePointKV(WithPrefix(keyspaceIdStr))
// To make sure some exists tests with async-commit or 1pc commit pass
opt = disableActiveActiveCommitSupport(opt...)
tikvStore, err := NewKVStore(uid, pdCli, spkv, client, opt...)

if txnLocalLatches > 0 {
Expand All @@ -153,3 +164,11 @@ func NewTestKeyspaceTiKVStore(client Client, pdClient pd.Client, clientHijack fu
tikvStore.mock = true
return tikvStore, err
}

// WithDisableActiveActiveCommitSupportForTest is used to disable active-active commit support for test.
// It should only be used in the test env.
func WithDisableActiveActiveCommitSupportForTest() Option {
return func(store *KVStore) {
store.disableActiveActiveCommitSupport = true
}
}
12 changes: 12 additions & 0 deletions txnkv/transaction/2pc.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ type kvstore interface {
IsClose() bool
// Go run the function in a separate goroutine.
Go(f func()) error
// IsActiveActiveCommitSupportDisabled indicates whether to disable active-active commit support.
// The default value is false, which disables the async-commit and 1PC to ensure the commit timestamp should
// always follow the constraint by PD settings `tso-unique-index`.
IsActiveActiveCommitSupportDisabled() bool
}

// twoPhaseCommitter executes a two-phase commit protocol.
Expand Down Expand Up @@ -1504,6 +1508,10 @@ func sendTxnHeartBeat(

// checkAsyncCommit checks if async commit protocol is available for current transaction commit, true is returned if possible.
func (c *twoPhaseCommitter) checkAsyncCommit() bool {
if !c.store.IsActiveActiveCommitSupportDisabled() {
return false
}

// Disable async commit in local transactions
if c.txn.GetScope() != oracle.GlobalTxnScope {
return false
Expand Down Expand Up @@ -1535,6 +1543,10 @@ func (c *twoPhaseCommitter) checkAsyncCommit() bool {

// checkOnePC checks if 1PC protocol is available for current transaction.
func (c *twoPhaseCommitter) checkOnePC() bool {
if !c.store.IsActiveActiveCommitSupportDisabled() {
return false
}

// Disable 1PC in local transactions
if c.txn.GetScope() != oracle.GlobalTxnScope {
return false
Expand Down
5 changes: 5 additions & 0 deletions txnkv/transaction/test_probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,11 @@ func (c CommitterProbe) CheckAsyncCommit() bool {
return c.checkAsyncCommit()
}

// CheckOnePC returns if 1pc commit is available.
func (c CommitterProbe) CheckOnePC() bool {
return c.checkOnePC()
}

// GetOnePCCommitTS returns the commit ts of one pc.
func (c CommitterProbe) GetOnePCCommitTS() uint64 {
return c.onePCCommitTS
Expand Down
Loading