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

store: update kvproto.CheckTxnStatus response #13432

Merged
merged 15 commits into from
Nov 18, 2019

Conversation

tiancaiamao
Copy link
Contributor

@tiancaiamao tiancaiamao commented Nov 13, 2019

What problem does this PR solve?

CheckTxnStatus should provide such kind of information, so we can find what's happening in the issue #13397

What 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 the minCommitTS is pushed.

Check List

Tests

  • Unit test

Side effects

  • Breaking backward compatibility

@tiancaiamao
Copy link
Contributor Author

/run-all-tests tikv=pr/5878

@tiancaiamao
Copy link
Contributor Author

/run-all-tests tikv=pr/5878

@codecov
Copy link

codecov bot commented Nov 13, 2019

Codecov Report

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

@@            Coverage Diff            @@
##            master    #13432   +/-   ##
=========================================
  Coverage   80.358%   80.358%           
=========================================
  Files          472       472           
  Lines       115172    115172           
=========================================
  Hits         92550     92550           
  Misses       15397     15397           
  Partials      7225      7225

@tiancaiamao
Copy link
Contributor Author

PTAL @coocood @youjiali1995 @MyonKeminta

@tiancaiamao
Copy link
Contributor Author

PTAL @coocood @youjiali1995 @MyonKeminta

Copy link
Contributor

@youjiali1995 youjiali1995 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 tiancaiamao added the status/LGT1 Indicates that a PR has LGTM 1. label Nov 15, 2019
@coocood
Copy link
Member

coocood commented Nov 15, 2019

LGTM

coocood
coocood previously approved these changes Nov 15, 2019
@coocood
Copy link
Member

coocood commented Nov 15, 2019

/merge

@sre-bot sre-bot added the status/can-merge Indicates a PR has been approved by a committer. label Nov 15, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Nov 15, 2019

/run-all-tests

@sre-bot
Copy link
Contributor

sre-bot commented Nov 15, 2019

@tiancaiamao merge failed.

@tiancaiamao
Copy link
Contributor Author

/run-all-tests

@tiancaiamao
Copy link
Contributor Author

PTAL @coocood @youjiali1995

@tiancaiamao
Copy link
Contributor Author

The kvproto has been updated to include this change: pingcap/kvproto#495
PTAL @coocood @youjiali1995

@tiancaiamao
Copy link
Contributor Author

/run-all-tests

@@ -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())
Copy link
Member

Choose a reason for hiding this comment

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

variable name should update

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -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))
Copy link
Member

Choose a reason for hiding this comment

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

log message need update

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@tiancaiamao tiancaiamao changed the title store: record rollback reason in kvproto.CheckTxnStatus response store: update kvproto.CheckTxnStatus response Nov 18, 2019
@tiancaiamao
Copy link
Contributor Author

/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
Copy link
Member

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

Copy link
Contributor Author

@tiancaiamao tiancaiamao Nov 18, 2019

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'

Comment on lines 109 to 113
type TxnStatus struct {
ttl uint64
commitTS uint64
action kvrpcpb.Action
}
Copy link
Contributor

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?

Copy link
Contributor Author

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

@tiancaiamao
Copy link
Contributor Author

/run-all-tests tikv=pr/5937

@tiancaiamao
Copy link
Contributor Author

/rebuild

Copy link
Contributor

@MyonKeminta MyonKeminta left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@youjiali1995 youjiali1995 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
Copy link
Contributor Author

/run-unit-test

Copy link
Member

@coocood coocood left a comment

Choose a reason for hiding this comment

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

LGTM

@coocood coocood merged commit 8401cbd into pingcap:master Nov 18, 2019
@tiancaiamao tiancaiamao deleted the rollback-reason branch November 20, 2019 08:44
XiaTianliang pushed a commit to XiaTianliang/tidb that referenced this pull request Dec 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/tikv status/can-merge Indicates a PR has been approved by a committer. status/LGT1 Indicates that a PR has LGTM 1.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants