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

*: implement the CheckTxnStatus API for the large transaction #11974

Merged
merged 12 commits into from
Sep 10, 2019

Conversation

tiancaiamao
Copy link
Contributor

What problem does this PR solve?

Implement a new kvproto API for the incoming large transaction support.

What is changed and how it works?

In the new kvproto, there will be a minCommitTS field, the large transaction will use it.

CheckTxnStatus checks the status of a transaction(on the primary key).
If the lock exists and is valid, CheckTxnStatus would push forward the minCommitTS using the current reader's startTS.

In this commit, I implement the API in the mocktikv, adding unit test, covering the storage and proto parts.

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change

@tiancaiamao
Copy link
Contributor Author

PTAL @coocood @lysu @sticnarf

@sticnarf sticnarf requested review from youjiali1995 and removed request for sticnarf September 2, 2019 04:56
@codecov
Copy link

codecov bot commented Sep 2, 2019

Codecov Report

Merging #11974 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #11974   +/-   ##
===========================================
  Coverage   81.4652%   81.4652%           
===========================================
  Files           451        451           
  Lines         97379      97379           
===========================================
  Hits          79330      79330           
  Misses        12400      12400           
  Partials       5649       5649

@coocood
Copy link
Member

coocood commented Sep 3, 2019

LGTM

@lysu lysu added the status/LGT1 Indicates that a PR has LGTM 1. label Sep 6, 2019

// If this is a large transaction and the lock is active, push forward the minCommitTS.
// lock.minCommitTS == 0 may be a secondary lock, or not a large transaction.
if lock.minCommitTS > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

does ther caller need to know if it did update the minCommitTS ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's unnecessary @cfzjywxk

@tiancaiamao
Copy link
Contributor Author

PTAL @crazycs520 @cfzjywxk @MyonKeminta

value: []byte{'d', 'e'},
op: kvrpcpb.Op_Put,
ttl: 444,
minCommitTS: 666,
Copy link
Contributor

Choose a reason for hiding this comment

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

Need check in the below

	c.Assert(l.minCommitTS, Equals, l1.minCommitTS)

ttl, commitTS, err = s.store.CheckTxnStatus([]byte("pk1"), 5, 0, 666)
c.Assert(err, IsNil)
c.Assert(ttl, Equals, uint64(0))
c.Assert(commitTS, Equals, uint64(0))
Copy link
Contributor

Choose a reason for hiding this comment

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

Add test for minCommitTS logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The minCommitTS is not returned in the CheckTxnStatus response, so we can't check it here.
Anyway, in the following PR we'll cover the minCommitTS
@crazycs520

@@ -370,7 +373,7 @@ func (lr *LockResolver) getTxnStatus(bo *Backoffer, txnID uint64, primary []byte
return status, err
}
if cmdResp.CommitVersion != 0 {
status = TxnStatus(cmdResp.GetCommitVersion())
status = TxnStatus{0, cmdResp.GetCommitVersion()}
Copy link
Contributor

Choose a reason for hiding this comment

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

ttl is always 0? change this later or?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the CleanUp proto, the result would be either committed or rollbacked, so the ttl is always 0.

@tiancaiamao
Copy link
Contributor Author

PTAL @crazycs520 @cfzjywxk

@cfzjywxk
Copy link
Contributor

LGTM

@tiancaiamao tiancaiamao added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Sep 10, 2019
Copy link
Contributor

@crazycs520 crazycs520 left a comment

Choose a reason for hiding this comment

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

LGTM

@tiancaiamao
Copy link
Contributor Author

/run-all-tests

@tiancaiamao tiancaiamao merged commit f01cb87 into pingcap:master Sep 10, 2019
@tiancaiamao tiancaiamao deleted the check-txn-status branch September 10, 2019 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/tikv sig/transaction SIG:Transaction status/LGT2 Indicates that a PR has LGTM 2. type/new-feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants