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

ttl: rollback the scan trasnaction even if the BEGIN failed. #58943

Merged
merged 1 commit into from
Jan 15, 2025

Conversation

YangKeao
Copy link
Member

@YangKeao YangKeao commented Jan 15, 2025

What problem does this PR solve?

Issue Number: close #58900

Problem Summary:

Previously, the RunInTxn will only rollback the transaction after the BEGIN runs successfully. However, if the BEGIN is killed after setting the transaction status, it can still leave a valid transaction. We'll need to also ROLLBACK it.

The effect is that when we are cancelling a TTL task (scaling the workers, stepping out of the TTL window, stopping the TTL function...), a session with valid transaction may pollute the session pool.

What changed and how does it work?

Move the defer ... ROLLBACK logic to the top of the RunInTxn function.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Release note

Fix the issue that canceling a TTL task may return a polluted session to global session pool.

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/needs-triage-completed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 15, 2025
@YangKeao
Copy link
Member Author

/check-issue-triage-complete

@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 15, 2025
@YangKeao YangKeao requested a review from lcwangchao January 15, 2025 09:07
Copy link

codecov bot commented Jan 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.5448%. Comparing base (9c01dcd) to head (0ae413f).
Report is 5 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #58943        +/-   ##
================================================
+ Coverage   73.1695%   73.5448%   +0.3753%     
================================================
  Files          1678       1680         +2     
  Lines        464110     465025       +915     
================================================
+ Hits         339587     342002      +2415     
+ Misses       103656     102143      -1513     
- Partials      20867      20880        +13     
Flag Coverage Δ
integration 42.8851% <0.0000%> (?)
unit 72.2773% <100.0000%> (-0.0843%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.6910% <ø> (ø)
parser ∅ <ø> (∅)
br 45.4402% <ø> (-0.2919%) ⬇️

@YangKeao YangKeao requested a review from hawkingrei January 15, 2025 09:15
@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jan 15, 2025
Copy link

ti-chi-bot bot commented Jan 15, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hawkingrei, lcwangchao

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [hawkingrei,lcwangchao]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jan 15, 2025
Copy link

ti-chi-bot bot commented Jan 15, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-01-15 09:20:33.328726669 +0000 UTC m=+110304.783772818: ☑️ agreed by hawkingrei.
  • 2025-01-15 09:26:40.238838327 +0000 UTC m=+110671.693884476: ☑️ agreed by lcwangchao.

@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Jan 15, 2025
@YangKeao YangKeao added needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. labels Jan 15, 2025
@ti-chi-bot ti-chi-bot bot merged commit e8f6026 into pingcap:master Jan 15, 2025
24 checks passed
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.1: #58948.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Jan 15, 2025
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #58949.

@YangKeao
Copy link
Member Author

Wow! It's merged so fast. Amazing.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.1: #58950.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.5: #58951.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TTL scan worker may put a not-committed session to the session pool
4 participants