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

session: fix a bug cause panic when retry is enable. #21285

Merged
merged 3 commits into from
Nov 25, 2020

Conversation

wjhuang2016
Copy link
Member

Signed-off-by: wjhuang2016 huangwenjun1997@gmail.com

What problem does this PR solve?

Issue Number: close #21284

Problem Summary:
When retry "SET SQL_SELECT_LIMIT=DEFAULT", txn is not valid.

What is changed and how it works?

Open a new transaction when retry.

Related changes

Check List

Tests

  • Unit test

Side effects

Release note

  • fix a bug cause panic when retry is enable.

Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
@wjhuang2016 wjhuang2016 added sig/transaction SIG:Transaction type/bugfix This PR fixes a bug. labels Nov 25, 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 ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Nov 25, 2020
@jackysp jackysp added the priority/release-blocker This issue blocks a release. Please solve it ASAP. label Nov 25, 2020
@jebter jebter added this to the v4.0.9 milestone Nov 25, 2020
@github-actions github-actions bot added the sig/execution SIG execution label Nov 25, 2020
@tiancaiamao
Copy link
Contributor

Problem Summary:
When retry "SET SQL_SELECT_LIMIT=DEFAULT", txn is not valid.

Why txn is not valid?
Since the old code uses PrepareTxnCtx, the transaction is not activated unless sctx.Txn(true) is called.

Why sctx.Txn(true) is not called?
SET SQL_SELECT_LIMIT=DEFAULT does not need to use txn, so sctx.Txn(true) is not called.

Where does the code panic?
st.MergeStmtKeyExistErrs() calls st.Transaction.MergeStmtKeyExistErrs() and st.Transaction is nil, so it panic there.

@tiancaiamao
Copy link
Contributor

LGTM

@ti-srebot ti-srebot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Nov 25, 2020
@tiancaiamao
Copy link
Contributor

PTAL @cfzjywxk

@cfzjywxk
Copy link
Contributor

LGTM

@ti-srebot ti-srebot added status/LGT3 The PR has already had 3 LGTM. and removed status/LGT2 Indicates that a PR has LGTM 2. labels Nov 25, 2020
@jackysp
Copy link
Member

jackysp commented Nov 25, 2020

/merge

@ti-srebot
Copy link
Contributor

Your auto merge job has been accepted, waiting for:

  • 21273
  • 21253

@ti-srebot ti-srebot added the status/can-merge Indicates a PR has been approved by a committer. label Nov 25, 2020
@jackysp
Copy link
Member

jackysp commented Nov 25, 2020

Don't forget to cherry-pick it to master.

@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot ti-srebot merged commit e0f9056 into pingcap:release-4.0 Nov 25, 2020
jackysp pushed a commit to jackysp/tidb that referenced this pull request Nov 26, 2020
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
@wjhuang2016 wjhuang2016 deleted the fix_txn_retry branch November 17, 2022 11:09
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/execution SIG execution sig/transaction SIG:Transaction 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.

6 participants