Skip to content

Conversation

Tristan1900
Copy link
Contributor

@Tristan1900 Tristan1900 commented Jan 6, 2025

What problem does this PR solve?

Issue Number: close #58725

Problem Summary:

What changed and how does it work?

  1. To allow parallel restore tasks, we introduced a restore id for each task, the id is allocated by an internal TiDB registry table and it's monotonic increasing, the table is in mysql db called tide_restore_registry
  2. We add this restore id to the suffix of checkpoint DB and storage, so each task can have their own checkpoint and not messing with others
  3. For each new task, it registers itself to the registry, and make sure tables it's going to restore is not overlapping with restore task that has a smaller restore id. If there is conflict it will abort the restore and show the reason.
  4. After finishing the restore, it will unregister itself from the registry
  5. In case of failure, for a graceful one, it will change the task status in registry from running to pause, so next time user can retry and reusing the checkpoint. If disaster happens like OOM that BR didn't get a chance to pause, user needs to manually clean it up. We have a heartbeat mechanism that update the restore task timestamp, it can provide some hints whether this task is active or orphaned.

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.

None

Copy link

ti-chi-bot bot commented Jan 6, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/needs-tests-checked do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 6, 2025
Copy link

tiprow bot commented Jan 6, 2025

Hi @Tristan1900. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@Tristan1900 Tristan1900 marked this pull request as ready for review January 6, 2025 22:25
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 6, 2025
Copy link

codecov bot commented Jan 6, 2025

Codecov Report

Attention: Patch coverage is 60.94771% with 239 lines in your changes missing coverage. Please review.

Project coverage is 74.9514%. Comparing base (35e7667) to head (d283e4b).
Report is 9 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #58724        +/-   ##
================================================
+ Coverage   73.1938%   74.9514%   +1.7576%     
================================================
  Files          1726       1751        +25     
  Lines        479561     490105     +10544     
================================================
+ Hits         351009     367341     +16332     
+ Misses       107030      99725      -7305     
- Partials      21522      23039      +1517     
Flag Coverage Δ
integration 48.7958% <60.6209%> (?)
unit 72.3310% <6.5359%> (-0.1279%) ⬇️

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

Components Coverage Δ
dumpling 52.7804% <ø> (ø)
parser ∅ <ø> (∅)
br 62.5304% <60.9917%> (+15.1004%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ti-chi-bot ti-chi-bot bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 6, 2025
@Tristan1900 Tristan1900 changed the title br: use dedicated checkpoint table for each restore task br: enable parallel restore Mar 19, 2025
@Tristan1900 Tristan1900 force-pushed the concurent-restore branch 4 times, most recently from d6875ff to d33d597 Compare March 27, 2025 02:44
@Tristan1900
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Mar 27, 2025

@Tristan1900: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@Tristan1900
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Mar 28, 2025

@Tristan1900: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@Leavrth Leavrth requested a review from Copilot April 11, 2025 08:27
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 14 out of 21 changed files in this pull request and generated no comments.

Files not reviewed (7)
  • br/pkg/registry/BUILD.bazel: Language not supported
  • br/pkg/restore/BUILD.bazel: Language not supported
  • br/pkg/task/BUILD.bazel: Language not supported
  • br/tests/br_parallel_restore/run.sh: Language not supported
  • br/tests/br_pitr/run.sh: Language not supported
  • br/tests/br_restore_checkpoint/run.sh: Language not supported
  • br/tests/run_group_br_tests.sh: Language not supported
Comments suppressed due to low confidence (1)

br/pkg/utils/schema.go:34

  • The comment contains a typo ('wheterh'); it should be corrected to 'whether'.
// IsTemplateSysDB checks wheterh the dbname is temporary system database(__TiDB_BR_Temporary_mysql or __TiDB_BR_Temporary_sys).

Comment on lines 55 to 60
filter_strings(255),
start_ts,
restored_ts,
upstream_cluster_id,
with_sys_table,
cmd(255)
Copy link
Contributor

Choose a reason for hiding this comment

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

for cmd column, maybe it is better to use enum type?
for filter_strings, I think 255 is not long enough for type Text.

ERROR 1062 (23000): Duplicate entry '1234567890123456789012345678901234567890123456789012345678901234' for key 't1.unique_registration_params'

Do you actually want KEY instead of UNIQUE KEY?

AND upstream_cluster_id = %%?
AND with_sys_table = %%?
AND cmd = %%?
ORDER BY id DESC LIMIT 1`
Copy link
Contributor

Choose a reason for hiding this comment

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

no need limit 1 because there must be only one row in the final result.

}
// task exists but was either created by another process or has been running
// check if it's in running state
runningRows, _, err := execCtx.ExecRestrictedSQL(
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it necessary to select again? runningRows[0] must be the same as rows[0].

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah yes you are right

if hasCheckpointPersisted(c, cfg) {
log.Info("pausing restore task from registry",
zap.Uint64("restoreId", cfg.RestoreID), zap.Error(restoreError))
if err := restoreRegistry.PauseTask(c, cfg.RestoreID); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

What if BR is killed because OOM? BR might not have chance to pause the task.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good call, let me think about that

return 0, errors.Annotatef(err, "failed to create new registration")
}

// check if a row with our parameters exists
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe after introduce a txn (begin ... commit), BR does not need to check again.

@ti-chi-bot ti-chi-bot bot added the sig/planner SIG: Planner label Jun 2, 2025
Signed-off-by: Wenqi Mou <[email protected]>
Signed-off-by: Wenqi Mou <[email protected]>
Signed-off-by: Wenqi Mou <[email protected]>
@Tristan1900
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Jun 2, 2025

@Tristan1900: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

with_sys_table BOOLEAN NOT NULL DEFAULT TRUE,
status VARCHAR(20) NOT NULL DEFAULT 'running',
cmd TEXT,
start_timestamp BIGINT UNSIGNED NOT NULL,

Choose a reason for hiding this comment

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

From a user perspective I find the column naming confusing.

First, it is not clear how this is different from start_ts referenced above. Can you clarifying the naming here? If they are used for different things, is the a better name that can be used to make it more obvious? Or is this just intended to offer different levels of precision (if so why the same data type)?

Second, the suffix of the column name _timestamp implies this is aTIMESTAMP while the type is specified as BIGINT. This is confusing and inconsistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for taking a look!
yes you are absolutely right the name is confusing, let me rename the latter one.

Signed-off-by: Wenqi Mou <[email protected]>
Copy link
Contributor

@windtalker windtalker left a comment

Choose a reason for hiding this comment

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

expression/executor part lgtm

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jun 3, 2025
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 3, 2025
Copy link

ti-chi-bot bot commented Jun 3, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-06-02 22:50:03.041854978 +0000 UTC m=+309289.244200244: ✖️🔁 reset by benmeadowcroft.
  • 2025-06-03 01:17:40.517597771 +0000 UTC m=+318146.719943037: ☑️ agreed by windtalker.
  • 2025-06-03 02:00:52.990407044 +0000 UTC m=+320739.192752308: ☑️ agreed by benmeadowcroft.

@D3Hunter
Copy link
Contributor

D3Hunter commented Jun 3, 2025

/approve

Copy link

ti-chi-bot bot commented Jun 3, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: benmeadowcroft, D3Hunter, Leavrth, windtalker, winoros

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:

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 the approved label Jun 3, 2025
@winoros
Copy link
Member

winoros commented Jun 3, 2025

for planner part

@ti-chi-bot ti-chi-bot bot merged commit fa3c79b into pingcap:master Jun 3, 2025
34 of 39 checks passed
Tristan1900 added a commit to Tristan1900/tidb that referenced this pull request Jun 6, 2025
joechenrh pushed a commit to joechenrh/tidb that referenced this pull request Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

br: use dedicated checkpoint table for each br task
8 participants