-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
store: update kvproto.CheckTxnStatus response #13432
Conversation
/run-all-tests tikv=pr/5878 |
/run-all-tests tikv=pr/5878 |
Codecov Report
@@ Coverage Diff @@
## master #13432 +/- ##
=========================================
Coverage 80.358% 80.358%
=========================================
Files 472 472
Lines 115172 115172
=========================================
Hits 92550 92550
Misses 15397 15397
Partials 7225 7225 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
LGTM |
/merge |
/run-all-tests |
@tiancaiamao merge failed. |
/run-all-tests |
d4ee01b
to
2ff5e70
Compare
PTAL @coocood @youjiali1995 |
The kvproto has been updated to include this change: pingcap/kvproto#495 |
/run-all-tests |
store/mockstore/mocktikv/rpc.go
Outdated
@@ -387,11 +387,11 @@ func (h *rpcHandler) handleKvCheckTxnStatus(req *kvrpcpb.CheckTxnStatusRequest) | |||
panic("KvCheckTxnStatus: key not in region") | |||
} | |||
var resp kvrpcpb.CheckTxnStatusResponse | |||
ttl, commitTS, err := h.mvccStore.CheckTxnStatus(req.GetPrimaryKey(), req.GetLockTs(), req.GetCallerStartTs(), req.GetCurrentTs(), req.GetRollbackIfNotExist()) | |||
ttl, commitTS, rollbackReason, err := h.mvccStore.CheckTxnStatus(req.GetPrimaryKey(), req.GetLockTs(), req.GetCallerStartTs(), req.GetCurrentTs(), req.GetRollbackIfNotExist()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variable name should update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
store/tikv/lock_test.go
Outdated
@@ -201,7 +201,7 @@ func (s *testLockSuite) TestGetTxnStatus(c *C) { | |||
status, err = s.store.lockResolver.GetTxnStatus(startTS, startTS, []byte("a")) | |||
c.Assert(err, IsNil) | |||
c.Assert(status.IsCommitted(), IsFalse) | |||
c.Assert(status.ttl, Greater, uint64(0)) | |||
c.Assert(status.ttl, Greater, uint64(0), Commentf("rollback reason:%s", status.action)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log message need update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
/run-all-tests |
@@ -1072,6 +1079,7 @@ func (mvcc *MVCCLevelDB) CheckTxnStatus(primaryKey []byte, lockTS, callerStartTS | |||
// We *must* guarantee the invariance lock.minCommitTS >= callerStartTS + 1 | |||
if lock.minCommitTS < callerStartTS+1 { | |||
lock.minCommitTS = callerStartTS + 1 | |||
action = kvrpcpb.Action_MinCommitTSPushed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to set this action even if minCommitTS is already greater than callerStartTS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, get it!
That information is actually 'could the caller read ignore the lock', rather than 'minCommitTS pushed'
type TxnStatus struct { | ||
ttl uint64 | ||
commitTS uint64 | ||
action kvrpcpb.Action | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this definition be moved to a better place in store
directory, so those CheckTxnStatus
functions can return this struct instead of returning its three fields in a long tuple?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would involve too many irrelevant changes in this PR
/run-all-tests tikv=pr/5937 |
/rebuild |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-all-tests |
/run-unit-test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What problem does this PR solve?
CheckTxnStatus
should provide such kind of information, so we can find what's happening in the issue #13397What is changed and how it works?
Record rollback reason in kvproto.CheckTxnStatus response, update the code.
Update:
Now the field name is changed to
action
, and the CheckTxnStatus response also contains the information whether theminCommitTS
is pushed.Check List
Tests
Side effects