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

session,store/tikv: make CI more stable #13303

Merged
merged 2 commits into from
Nov 9, 2019
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
2 changes: 1 addition & 1 deletion session/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (s *testSessionSuite) TestErrorRollback(c *C) {
var wg sync.WaitGroup
cnt := 4
wg.Add(cnt)
num := 100
num := 20
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it OK to decrease the tested number?

Would you please give some explains why this test become slower since the related PR is merged

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it OK to decrease the tested number?

I guess so, at lease the change doesn't affect the correctness.

The ResolveLocks function is more sensitivity than before, in a heavy write conflict sense the contention increase.


for i := 0; i < cnt; i++ {
go func() {
Expand Down
26 changes: 12 additions & 14 deletions store/tikv/lock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,7 @@ func (s *testLockSuite) TestCheckTxnStatusTTL(c *C) {
txn, err := s.store.Begin()
c.Assert(err, IsNil)
txn.Set(kv.Key("key"), []byte("value"))
committer, err := newTwoPhaseCommitterWithInit(txn.(*tikvTxn), 0)
c.Assert(err, IsNil)
// Increase lock TTL to make CI more stable.
committer.lockTTL = txnLockTTL(txn.(*tikvTxn).startTime, 200*1024*1024)
err = committer.prewriteKeys(NewBackoffer(context.Background(), PrewriteMaxBackoff), committer.keys)
c.Assert(err, IsNil)
s.prewriteTxnWithTTL(c, txn.(*tikvTxn), 1000)

bo := NewBackoffer(context.Background(), PrewriteMaxBackoff)
lr := newLockResolver(s.store)
Expand Down Expand Up @@ -279,12 +274,7 @@ func (s *testLockSuite) TestCheckTxnStatus(c *C) {
c.Assert(err, IsNil)
txn.Set(kv.Key("key"), []byte("value"))
txn.Set(kv.Key("second"), []byte("xxx"))
committer, err := newTwoPhaseCommitterWithInit(txn.(*tikvTxn), 0)
c.Assert(err, IsNil)
// Increase lock TTL to make CI more stable.
committer.lockTTL = txnLockTTL(txn.(*tikvTxn).startTime, 200*1024*1024)
err = committer.prewriteKeys(NewBackoffer(context.Background(), PrewriteMaxBackoff), committer.keys)
c.Assert(err, IsNil)
s.prewriteTxnWithTTL(c, txn.(*tikvTxn), 1000)

oracle := s.store.GetOracle()
currentTS, err := oracle.GetTimestamp(context.Background())
Expand Down Expand Up @@ -387,8 +377,16 @@ func (s *testLockSuite) TestCheckTxnStatusNoWait(c *C) {
}

func (s *testLockSuite) prewriteTxn(c *C, txn *tikvTxn) {
s.prewriteTxnWithTTL(c, txn, 0)
}

func (s *testLockSuite) prewriteTxnWithTTL(c *C, txn *tikvTxn, ttl uint64) {
committer, err := newTwoPhaseCommitterWithInit(txn, 0)
c.Assert(err, IsNil)
if ttl > 0 {
elapsed := time.Since(txn.startTime) / time.Millisecond
committer.lockTTL = uint64(elapsed) + ttl
}
err = committer.prewriteKeys(NewBackoffer(context.Background(), PrewriteMaxBackoff), committer.keys)
c.Assert(err, IsNil)
}
Expand Down Expand Up @@ -429,7 +427,7 @@ func (s *testLockSuite) TestLockTTL(c *C) {
c.Assert(err, IsNil)
txn.Set(kv.Key("key"), []byte("value"))
time.Sleep(time.Millisecond)
s.prewriteTxn(c, txn.(*tikvTxn))
s.prewriteTxnWithTTL(c, txn.(*tikvTxn), 1000)
l := s.mustGetLock(c, []byte("key"))
c.Assert(l.TTL >= defaultLockTTL, IsTrue)

Expand Down Expand Up @@ -461,7 +459,7 @@ func (s *testLockSuite) TestBatchResolveLocks(c *C) {
txn, err := s.store.Begin()
c.Assert(err, IsNil)
txn.Set(kv.Key("key"), []byte("value"))
s.prewriteTxn(c, txn.(*tikvTxn))
s.prewriteTxnWithTTL(c, txn.(*tikvTxn), 1000)
l := s.mustGetLock(c, []byte("key"))
msBeforeLockExpired := s.store.GetOracle().UntilExpired(l.TxnID, l.TTL)
c.Assert(msBeforeLockExpired, Greater, int64(0))
Expand Down