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/tikv: fix lockTTL too large if local time is behind timestamp. #13865

Merged
merged 3 commits into from
Dec 3, 2019

Conversation

coocood
Copy link
Member

@coocood coocood commented Dec 3, 2019

What problem does this PR solve?

elapsed time should only be calculated by local time, otherwise it may be negative and cast to uint64, a value that is too large.

What is changed and how it works?

Use txn.startTime to calculate elapsed time.

Check List

Tests

  • Unit test

Related changes

  • Need to cherry-pick to the release branch

Release note

  • fix lockTTL too large if local time is behind pd timestamp.

@codecov
Copy link

codecov bot commented Dec 3, 2019

Codecov Report

Merging #13865 into master will decrease coverage by 0.9355%.
The diff coverage is 100%.

@@               Coverage Diff               @@
##             master    #13865        +/-   ##
===============================================
- Coverage   81.0525%   80.117%   -0.9356%     
===============================================
  Files           478       474         -4     
  Lines        124270    117085      -7185     
===============================================
- Hits         100724     93805      -6919     
+ Misses        16053     15852       -201     
+ Partials       7493      7428        -65

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

AndreMouche
AndreMouche previously approved these changes Dec 3, 2019
Copy link
Contributor

@AndreMouche AndreMouche left a comment

Choose a reason for hiding this comment

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

LGTM

txn.startTS = oracle.ComposeTS(oracle.GetPhysical(time.Now().Add(time.Second*10)), 1)
txn.SetOption(kv.Pessimistic, true)
time.Sleep(time.Millisecond * 100)
err := txn.LockKeys(context.Background(), nil, txn.startTS, kv.LockAlwaysWait, key)
Copy link
Contributor

Choose a reason for hiding this comment

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

Previous code also includes the problem that forUpdateTS is used to calculate TTL by mistake. Need we use a bit larger forUpdateTS here?

txn := s.begin(c)
txn.startTS = oracle.ComposeTS(oracle.GetPhysical(time.Now().Add(time.Second*10)), 1)
txn.SetOption(kv.Pessimistic, true)
time.Sleep(time.Millisecond * 100)
Copy link
Contributor

Choose a reason for hiding this comment

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

Seem it is not a stability test

Copy link
Member Author

Choose a reason for hiding this comment

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

The ttl check is relaxed to 50ms delay.

@coocood
Copy link
Member Author

coocood commented Dec 3, 2019

@AndreMouche @youjiali1995 @sticnarf PTAL

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

@coocood
Copy link
Member Author

coocood commented Dec 3, 2019

/run-unit-test

@sticnarf
Copy link
Contributor

sticnarf commented Dec 3, 2019

LGTM

@coocood
Copy link
Member Author

coocood commented Dec 3, 2019

/merge

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

sre-bot commented Dec 3, 2019

/run-all-tests

@coocood coocood added the status/LGT3 The PR has already had 3 LGTM. label Dec 3, 2019
@sre-bot sre-bot merged commit a1adfb8 into pingcap:master Dec 3, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Dec 3, 2019

cherry pick to release-3.0 failed

@sre-bot
Copy link
Contributor

sre-bot commented Apr 7, 2020

It seems that, not for sure, we failed to cherry-pick this commit to release-3.0. Please comment '/run-cherry-picker' to try to trigger the cherry-picker if we did fail to cherry-pick this commit before. @coocood PTAL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/can-merge Indicates a PR has been approved by a committer. status/LGT3 The PR has already had 3 LGTM. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants