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: use a pessimistic transaction to finish the job #56516

Merged
merged 1 commit into from
Oct 10, 2024

Conversation

YangKeao
Copy link
Member

@YangKeao YangKeao commented Oct 9, 2024

What problem does this PR solve?

Issue Number: close #56422

Problem Summary:

When the job is finished, and at the same time the task is assigned to some TiDB node, it may fail to finish the job.

What changed and how does it work?

Use the pessimistic transaction to finish job. Then the DELETE ... FROM tidb_ttl_tasks will block UPDATE mysql.tidb_ttl_task SET owner_id = ?... (or in another direction).

If the ttl task is removed, it'll finally be removed by (m *taskManager) checkInvalidTask in the memory.

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.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

Fix the issue that a TTL job cannot be finished in some situation.

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-triage-completed release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 9, 2024
@YangKeao YangKeao requested a review from lcwangchao October 9, 2024 15:07
Copy link

codecov bot commented Oct 9, 2024

Codecov Report

Attention: Patch coverage is 77.77778% with 6 lines in your changes missing coverage. Please review.

Project coverage is 75.9269%. Comparing base (1eb0c8c) to head (78b2783).
Report is 142 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #56516        +/-   ##
================================================
+ Coverage   73.3698%   75.9269%   +2.5571%     
================================================
  Files          1626       1627         +1     
  Lines        448852     455007      +6155     
================================================
+ Hits         329322     345473     +16151     
+ Misses        99364      88884     -10480     
- Partials      20166      20650       +484     
Flag Coverage Δ
integration 49.2718% <0.0000%> (?)
unit 72.9317% <77.7777%> (+0.4685%) ⬆️

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

Components Coverage Δ
dumpling 52.9478% <ø> (ø)
parser ∅ <ø> (∅)
br 52.3655% <ø> (+6.7886%) ⬆️

@YangKeao
Copy link
Member Author

/retest

@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 Oct 10, 2024
@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Oct 10, 2024
@YangKeao YangKeao requested a review from bb7133 October 10, 2024 10:22
Copy link

ti-chi-bot bot commented Oct 10, 2024

[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 Oct 10, 2024
Copy link

ti-chi-bot bot commented Oct 10, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-10-10 08:31:13.638547442 +0000 UTC m=+1121229.058760449: ☑️ agreed by lcwangchao.
  • 2024-10-10 15:33:13.406895573 +0000 UTC m=+1146548.827108577: ☑️ agreed by hawkingrei.

@YangKeao
Copy link
Member Author

/retest

@ti-chi-bot ti-chi-bot bot merged commit 93cad31 into pingcap:master Oct 10, 2024
23 checks passed
@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. labels Oct 29, 2024
@ti-chi-bot
Copy link
Member

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

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Oct 29, 2024
@ti-chi-bot
Copy link
Member

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

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Oct 29, 2024
@ti-chi-bot
Copy link
Member

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

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Oct 29, 2024
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. 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 Task will not be canceled if facing write conflict
4 participants