Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test:stablize test case prewrite secondaries #18751

Merged
merged 4 commits into from
Jul 24, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions store/tikv/2pc.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ type twoPhaseCommitter struct {
testingKnobs struct {
acAfterCommitPrimary chan struct{}
bkAfterCommitPrimary chan struct{}
noFallBack bool
}

useAsyncCommit uint32
Expand Down
8 changes: 5 additions & 3 deletions store/tikv/2pc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var _ = SerialSuites(&testCommitterSuite{})
func (s *testCommitterSuite) SetUpSuite(c *C) {
atomic.StoreUint64(&ManagedLockTTL, 3000) // 3s
s.OneByOneSuite.SetUpSuite(c)
CommitMaxBackoff = 1000
}

func (s *testCommitterSuite) SetUpTest(c *C) {
Expand Down Expand Up @@ -77,7 +78,6 @@ func (s *testCommitterSuite) SetUpTest(c *C) {
// c.Assert(err, IsNil)

s.store = store
CommitMaxBackoff = 1000
}

func (s *testCommitterSuite) TearDownSuite(c *C) {
Expand Down Expand Up @@ -1137,7 +1137,7 @@ func (s *testCommitterSuite) TestResolveMixed(c *C) {

// TestSecondaryKeys tests that when async commit is enabled, each prewrite message includes an
// accurate list of secondary keys.
func (s *testCommitterSuite) TestPrewiteSecondaryKeys(c *C) {
func (s *testCommitterSuite) TestPrewriteSecondaryKeys(c *C) {
defer config.RestoreFunc()()
config.UpdateGlobal(func(conf *config.Config) {
conf.TiKVClient.EnableAsyncCommit = true
Expand Down Expand Up @@ -1169,9 +1169,11 @@ func (s *testCommitterSuite) TestPrewiteSecondaryKeys(c *C) {
ctx := context.Background()
// TODO remove this when minCommitTS is returned from mockStore prewrite response.
committer.minCommitTS = committer.startTS + 10
committer.testingKnobs.noFallBack = true
err = committer.execute(ctx)
c.Assert(err, IsNil)
c.Assert(mock.seenPrimaryReq > 0 && mock.seenSecondaryReq > 0, IsTrue)
c.Assert(mock.seenPrimaryReq > 0, IsTrue)
c.Assert(mock.seenSecondaryReq > 0, IsTrue)
}

func (s *testCommitterSuite) TestAsyncCommit(c *C) {
Expand Down
3 changes: 3 additions & 0 deletions store/tikv/prewrite.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ func (action actionPrewrite) handleSingleBatch(c *twoPhaseCommitter, bo *Backoff
// commit cannot proceed. The client can then fallback to normal way to
// continue committing the transaction if prewrite are all finished.
if prewriteResp.MinCommitTs == 0 {
if c.testingKnobs.noFallBack {
return nil
}
logutil.Logger(bo.ctx).Warn("async commit cannot proceed since the returned minCommitTS is zero, "+
"fallback to normal path", zap.Uint64("startTS", c.startTS))
c.setAsyncCommit(false)
Expand Down