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

txn: restore failed due to file end key is empty #52572

Merged
merged 4 commits into from
Apr 29, 2024

Conversation

3pointer
Copy link
Contributor

@3pointer 3pointer commented Apr 12, 2024

What problem does this PR solve?

Issue Number: close #52574

Problem Summary:
Restore txn kv might failed about handling empty end key. This PR fixed it.

What changed and how does it work?

Don't encode empty value of end key.

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 restore txn kv may report invalid range error.

Copy link

ti-chi-bot bot commented Apr 12, 2024

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 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. release-note-none size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 12, 2024
Copy link

tiprow bot commented Apr 12, 2024

Hi @3pointer. 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/test-infra repository.

@3pointer 3pointer marked this pull request as ready for review April 12, 2024 09:09
@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 Apr 12, 2024
Copy link

codecov bot commented Apr 12, 2024

Codecov Report

Attention: Patch coverage is 92.85714% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 56.2314%. Comparing base (1d698c7) to head (a75000b).
Report is 5 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #52572         +/-   ##
=================================================
- Coverage   72.3811%   56.2314%   -16.1497%     
=================================================
  Files          1482       1595        +113     
  Lines        428743     598501     +169758     
=================================================
+ Hits         310329     336546      +26217     
- Misses        99115     238482     +139367     
- Partials      19299      23473       +4174     
Flag Coverage Δ
integration 37.8444% <92.8571%> (?)
unit 71.2276% <71.4285%> (+0.0091%) ⬆️

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

Components Coverage Δ
dumpling 53.9957% <ø> (ø)
parser ∅ <ø> (∅)
br 60.8524% <92.8571%> (+19.7085%) ⬆️

@3pointer
Copy link
Contributor Author

/test unit-test

Copy link

tiprow bot commented Apr 15, 2024

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

In response to this:

/test unit-test

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/test-infra repository.

Copy link
Contributor

@YuJuncen YuJuncen left a comment

Choose a reason for hiding this comment

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

rest LGTM

@@ -1588,7 +1588,10 @@ func (rc *Client) WaitForFilesRestored(ctx context.Context, files []*backuppb.Fi
fileReplica := file
rc.workerPool.ApplyOnErrorGroup(eg,
func() error {
defer updateCh.Inc()
defer func() {
log.Info("import sst files done", logutil.Files(files))
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this be too verbose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tidb backup also have the same log. I think it's okay when restore a large amount data. it's better to know br is importing rather than nothing output.

if err != nil {
return nil, nil, errors.Trace(err)
}
return start, end, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe just return GetRewriteRawKeys(f, rules)?

Copy link

ti-chi-bot bot commented Apr 26, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Leavrth, YuJuncen

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 lgtm label Apr 26, 2024
Copy link

ti-chi-bot bot commented Apr 26, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-04-17 07:04:10.479333757 +0000 UTC m=+408069.590380218: ☑️ agreed by Leavrth.
  • 2024-04-26 09:51:26.311985698 +0000 UTC m=+5240.069121265: ☑️ agreed by YuJuncen.

Copy link

tiprow bot commented Apr 26, 2024

@3pointer: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
tidb_parser_test 5cac090 link true /test tidb_parser_test

Full PR test history. Your PR dashboard.

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/test-infra repository. I understand the commands that are listed here.

@3pointer
Copy link
Contributor Author

/test unit-test

Copy link

tiprow bot commented Apr 29, 2024

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

In response to this:

/test unit-test

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/test-infra repository.

@ti-chi-bot ti-chi-bot bot merged commit 5333ac3 into pingcap:master Apr 29, 2024
22 checks passed
@fancy-lee
Copy link

fancy-lee commented May 11, 2024

Does br txn support incremental backup? How to use br txn for incremental backup?

@YuJuncen
Copy link
Contributor

For now br txn doesn't support incremental backup. Providing --last-backup-ts in br txn is an no-op.

@fancy-lee
Copy link

For now br txn doesn't support incremental backup. Providing --last-backup-ts in br txn is an no-op.

Do you have any plans to implement this feature?

@YuJuncen
Copy link
Contributor

YuJuncen commented May 11, 2024

Do you have any plans to implement this feature?

For now, no. 😢

But you may try to implement a tiny version manually, that is, parse the argument --last-backup-ts and fill its value at br/pkg/task/backup_txn.go:192.

Then it might be able to backup the diff between last backup and now(but still not a real-time continuous backup.). Also notice this may not be pretty useful as it requires the gc safe point doesn't exceed the last_backup_ts.

@fancy-lee
Copy link

Do you have any plans to implement this feature?

For now, no. 😢

But you may try to implement a tiny version manually, that is, parse the argument --last-backup-ts and fill its value at br/pkg/task/backup_txn.go:192.

Then it might be able to backup the diff between last backup and now(but still not a real-time continuous backup.). Also notice this may not be pretty useful as it requires the gc safe point doesn't exceed the last_backup_ts.

Can the continuity of backups be ensured by disabling the GC or increasing the time of tidb_gc_life_time or tidb_gc_run_interval, and increasing the frequency of incremental backups

@YuJuncen
Copy link
Contributor

Can the continuity of backups be ensured by disabling the GC or increasing the time of tidb_gc_life_time or tidb_gc_run_interval, and increasing the frequency of incremental backups.

Perhaps, backing up diffs then restore them one-by-one probably works. In fact backing up txn data is simpler because we have get rid of the DDLs and table schemas. The potential problem is that nobody have tested this as far as I know - theoretically it works, but when you use it, you are in risk.

BTW discussing this topic here is somehow beyond this PR. Could you open an issue for further discussion?

@fancy-lee
Copy link

When executing the br back txn or br restore txn commands, a large number of log errors are output:

[2024/05/16 08:46:31.444 +08:00] [ERROR] [client.go:226] ["[pd] request failed with a non-200 status"] [source=tikv-driver] [name=GetMinResolvedTSByStoresIDs] [url=http://idc02-jfs01-tikv-backup-003.hogpu.cc:2379/pd/api/v1/min-resolved-ts] [method=GET] [caller-id=pd-http-client] [status="404 Not Found"] [body="404 page not found\n"] [stack="github.com/tikv/pd/client/http.(*clientInner).doRequest\n\t/home/go21path/pkg/mod/github.com/tikv/pd/client@v0.0.0-20240322051414-fb9e2d561b6e/http/client.go:226\ngithub.com/tikv/pd/client/http.(*clientInner).requestWithRetry.func1\n\t/home/go21path/pkg/mod/github.com/tikv/pd/client@v0.0.0-20240322051414-fb9e2d561b6e/http/client.go:134\ngithub.com/tikv/pd/client/http.(*clientInner).requestWithRetry\n\t/home/go21path/pkg/mod/github.com/tikv/pd/client@v0.0.0-20240322051414-fb9e2d561b6e/http/client.go:144\ngithub.com/tikv/pd/client/http.(*client).request\n\t/home/go21path/pkg/mod/github.com/tikv/pd/client@v0.0.0-20240322051414-fb9e2d561b6e/http/client.go:363\ngithub.com/tikv/pd/client/http.(*client).GetMinResolvedTSByStoresIDs\n\t/home/go21path/pkg/mod/github.com/tikv/pd/client@v0.0.0-20240322051414-fb9e2d561b6e/http/interface.go:864\ngithub.com/tikv/client-go/v2/tikv.(*KVStore).getMinResolvedTSByStoresIDs\n\t/home/go21path/pkg/mod/github.com/tikv/client-go/v2@v2.0.8-0.20240322070737-05aaba6cc6f7/tikv/kv.go:751\ngithub.com/tikv/client-go/v2/tikv.(*KVStore).updateGlobalTxnScopeTSFromPD\n\t/home/go21path/pkg/mod/github.com/tikv/client-go/v2@v2.0.8-0.20240322070737-05aaba6cc6f7/tikv/kv.go:785\ngithub.com/tikv/client-go/v2/tikv.(*KVStore).updateSafeTS\n\t/home/go21path/pkg/mod/github.com/tikv/client-go/v2@v2.0.8-0.20240322070737-05aaba6cc6f7/tikv/kv.go:654\ngithub.com/tikv/client-go/v2/tikv.(*KVStore).safeTSUpdater\n\t/home/go21path/pkg/mod/github.com/tikv/client-go/v2@v2.0.8-0.20240322070737-05aaba6cc6f7/tikv/kv.go:647"]
[2024/05/16 08:46:31.444 +08:00] [ERROR] [client.go:226] ["[pd] request failed with a non-200 status"] [source=tikv-driver] [name=GetMinResolvedTSByStoresIDs] [url=http://idc02-jfs01-tikv-backup-003.hogpu.cc:2379/pd/api/v1/min-resolved-ts] [method=GET] [caller-id=pd-http-client] [status="404 Not Found"] [body="404 page not found\n"] [stack="github.com/tikv/pd/client/http.(*clientInner).doRequest\n\t/home/go21path/pkg/mod/github.com/tikv/pd/client@v0.0.0-20240322051414-fb9e2d561b6e/http/client.go:226\ngithub.com/tikv/pd/client/http.(*clientInner).requestWithRetry.func1\n\t/home/go21path/pkg/mod/github.com/tikv/pd/client@v0.0.0-20240322051414-fb9e2d561b6e/http/client.go:134\ngithub.com/tikv/pd/client/http.(*clientInner).requestWithRetry\n\t/home/go21path/pkg/mod/github.com/tikv/pd/client@v0.0.0-20240322051414-fb9e2d561b6e/http/client.go:144\ngithub.com/tikv/pd/client/http.(*client).request\n\t/home/go21path/pkg/mod/github.com/tikv/pd/client@v0.0.0-20240322051414-fb9e2d561b6e/http/client.go:363\ngithub.com/tikv/pd/client/http.(*client).GetMinResolvedTSByStoresIDs\n\t/home/go21path/pkg/mod/github.com/tikv/pd/client@v0.0.0-20240322051414-fb9e2d561b6e/http/interface.go:864\ngithub.com/tikv/client-go/v2/tikv.(*KVStore).getMinResolvedTSByStoresIDs\n\t/home/go21path/pkg/mod/github.com/tikv/client-go/v2@v2.0.8-0.20240322070737-05aaba6cc6f7/tikv/kv.go:751\ngithub.com/tikv/client-go/v2/tikv.(*KVStore).updateSafeTS\n\t/home/go21path/pkg/mod/github.com/tikv/client-go/v2@v2.0.8-0.20240322070737-05aaba6cc6f7/tikv/kv.go:673\ngithub.com/tikv/client-go/v2/tikv.(*KVStore).safeTSUpdater\n\t/home/go21path/pkg/mod/github.com/tikv/client-go/v2@v2.0.8-0.20240322070737-05aaba6cc6f7/tikv/kv.go:647"]

What is the cause? Is there any impact on backup and recovery?

@ti-chi-bot
Copy link
Member

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

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.5 release-note 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.

Restore txn kv fails and reports ErrRestoreInvalidRange
6 participants