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

tikv: fix primary selection when delete-your-writes #18244

Merged
merged 2 commits into from
Jun 29, 2020
Merged

tikv: fix primary selection when delete-your-writes #18244

merged 2 commits into from
Jun 29, 2020

Conversation

lysu
Copy link
Contributor

@lysu lysu commented Jun 28, 2020

What problem does this PR solve?

Issue Number: close #xxx

Problem Summary:

  1. Push down condition check to TiKV for prewrite request #9127 introduce addition useless but sometime wrong DEL mutation for delete-your-writes
  2. store: check constraint for "Delete-Your-Writes" records when txn commit #14968 try to remove wrong DEL mutation
  3. but wrong DEL mutation can take role as 2pc primary key(or transaction record) to works well in some situation, but store: check constraint for "Delete-Your-Writes" records when txn commit #14968 remove it will cause prewrite locks's primary property point to a unwriten primary key
  4. any read-write request see those uncommited lock with wrong primary key value will treat them belong rollbacked transaction, but real transaction invoker maybe think transaction has be success.

so it will cause read/write inconsistent result when meet lock that point to a primary key has be insert/delete in own txn.

https://github.com/pingcap/tidb/pull/18244/files#diff-d11e207d2529a00e79d72b84ae5172caR722 will fail and read nothing to reproduce it in 2pc test case level.

What is changed and how it works?

What's Changed, How it Works:

choose first key didn't be delete by itself as primary key.

Related changes

  • Need to cherry-pick to the release branch 3.0

Check List

Tests

  • Unit test

Side effects

  • n/a

Release note

  • Fix read/write inconsistent result when meet lock that point to a primary key has be insert/delete in own txn

This change is Reviewable

@codecov
Copy link

codecov bot commented Jun 28, 2020

Codecov Report

Merging #18244 into master will decrease coverage by 0.1122%.
The diff coverage is 100.0000%.

@@               Coverage Diff                @@
##             master     #18244        +/-   ##
================================================
- Coverage   79.5531%   79.4408%   -0.1123%     
================================================
  Files           535        535                
  Lines        144443     143907       -536     
================================================
- Hits         114909     114321       -588     
- Misses        20268      20319        +51     
- Partials       9266       9267         +1     

@lysu
Copy link
Contributor Author

lysu commented Jun 28, 2020

/run-all-tests

@lysu lysu added this to the v4.0.2 milestone Jun 28, 2020
@lysu lysu added priority/release-blocker This issue blocks a release. Please solve it ASAP. status/all-tests-passed labels Jun 28, 2020
Copy link
Member

@jackysp jackysp left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot
Copy link
Contributor

@jackysp,Thanks for you review.

Copy link
Contributor

@bobotu bobotu left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot
Copy link
Contributor

@bobotu,Thanks for you review.

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

@ti-srebot
Copy link
Contributor

@coocood,Thanks for you review.

@coocood coocood merged commit 3eaee1a into pingcap:master Jun 29, 2020
ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Jun 29, 2020
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-3.0 in PR #18248

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Jun 29, 2020
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-3.1 in PR #18249

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Jun 29, 2020
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-4.0 in PR #18250

@lysu lysu deleted the dev-fix-wrong-primary-selection-when-delete-your-write branch June 29, 2020 01:33
jebter pushed a commit that referenced this pull request Jun 29, 2020
* cherry pick #18244 to release-4.0

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>

* fix test compile

Co-authored-by: lysu <sulifx@gmail.com>
ti-srebot added a commit that referenced this pull request Jun 29, 2020
* cherry pick #18244 to release-3.0

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>

* fix conflict to 4.0

* fix test case

Co-authored-by: lysu <sulifx@gmail.com>
ti-srebot added a commit that referenced this pull request Jun 29, 2020
* cherry pick #18244 to release-3.1

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>

* fix conflict to 3.1

* fix test case

Co-authored-by: lysu <sulifx@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/release-blocker This issue blocks a release. Please solve it ASAP. sig/transaction SIG:Transaction type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants