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

lightning: fix id too large after parallel import #57398

Merged
merged 12 commits into from
Nov 19, 2024

Conversation

D3Hunter
Copy link
Contributor

@D3Hunter D3Hunter commented Nov 15, 2024

What problem does this PR solve?

Issue Number: close #56814

Problem Summary:

What changed and how does it work?

previously with parallel import, the auto id after import is the estimated ones even though there are IDs inside the data source file, we change to the ones inside the data source file to avoid next auto id too large

to do this, we need to save different values for different auto id in checkpoint

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
    • parallel import with 2 instances, next id is the max id in data files + 1
    • open parallel import, but start instance B after the first instance finish, so we can see B is checksuming existing data, and success
  • 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

@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. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 15, 2024
Copy link

tiprow bot commented Nov 15, 2024

Hi @D3Hunter. 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.

Comment on lines +324 to +325
// if another instance finished import before below checksum logic,
// it will cause checksum mismatch, but it's very rare.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

see #57399

Copy link

codecov bot commented Nov 15, 2024

Codecov Report

Attention: Patch coverage is 78.41410% with 49 lines in your changes missing coverage. Please review.

Project coverage is 74.0038%. Comparing base (a5832b4) to head (3889d53).
Report is 181 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #57398        +/-   ##
================================================
+ Coverage   72.9011%   74.0038%   +1.1026%     
================================================
  Files          1668       1702        +34     
  Lines        461134     480713     +19579     
================================================
+ Hits         336172     355746     +19574     
+ Misses       104308     103452       -856     
- Partials      20654      21515       +861     
Flag Coverage Δ
integration 46.4629% <74.8898%> (?)
unit 72.4956% <56.2500%> (+0.2109%) ⬆️

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

Components Coverage Δ
dumpling 52.7673% <ø> (ø)
parser ∅ <ø> (∅)
br 44.4313% <ø> (-0.6780%) ⬇️

@D3Hunter
Copy link
Contributor Author

@lance6716 ping

Copy link
Contributor

@lance6716 lance6716 left a comment

Choose a reason for hiding this comment

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

(will review soon)

Makefile Outdated
@@ -530,7 +530,7 @@ br_bins:

.PHONY: data_parsers
data_parsers: tools/bin/vfsgendev pkg/lightning/mydump/parser_generated.go lightning_web
PATH="$(GOPATH)/bin":"$(PATH)":"$(TOOLS)" protoc -I. -I"$(GOPATH)/src" pkg/lightning/checkpoints/checkpointspb/file_checkpoints.proto --gogofaster_out=.
PATH="$(GOPATH)/bin":"$(PATH)":"$(TOOLS)" protoc -I. -I"$(GOPATH)/pkg/mod" pkg/lightning/checkpoints/checkpointspb/file_checkpoints.proto --gogofaster_out=.
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe use GOMODCACHE value from go env

https://go.dev/ref/mod#environment-variables

Copy link
Contributor

@lance6716 lance6716 left a comment

Choose a reason for hiding this comment

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

15 / 32 files viewed

@@ -188,22 +188,31 @@ func (m *dbTableMetaMgr) AllocTableRowIDs(ctx context.Context, rawRowIDMax int64
DB: conn,
Logger: m.tr.logger,
}
var newRowIDBase, newRowIDMax int64
curStatus := metaStatusInitial
// (myStartRowID, myEndRowID] is the range of row_id that current instance
Copy link
Contributor

Choose a reason for hiding this comment

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

can we use [start, end)? This is a bit strange and we have to -1 in GetMaxAutoIDBAse

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's how auto id allocator works now, both in TiDB and lightning, won't do it here

Copy link
Contributor

@lance6716 lance6716 left a comment

Choose a reason for hiding this comment

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

27 / 32 files viewed

@@ -1990,20 +1990,12 @@ type deliverResult struct {
}

func saveCheckpoint(rc *Controller, t *TableImporter, engineID int32, chunk *checkpoints.ChunkCheckpoint) {
// We need to update the AllocBase every time we've finished a file.
Copy link
Contributor

Choose a reason for hiding this comment

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

this line of comment can be kept. Maybe it reminds us to keep the consistency of "ID used for encoding data" and "ID saved in checkpoint"

lightning/pkg/importer/table_import.go Show resolved Hide resolved
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Nov 18, 2024
Copy link

ti-chi-bot bot commented Nov 18, 2024

@lance6716: Your lgtm message is repeated, so it is ignored.

In response to this:

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

@GMHDBJD GMHDBJD left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

ti-chi-bot bot commented Nov 19, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: GMHDBJD, lance6716

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 approved lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Nov 19, 2024
Copy link

ti-chi-bot bot commented Nov 19, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-11-18 11:29:13.95091031 +0000 UTC m=+874116.141779300: ☑️ agreed by lance6716.
  • 2024-11-19 05:58:16.14053605 +0000 UTC m=+940658.331405044: ☑️ agreed by GMHDBJD.

Copy link

tiprow bot commented Nov 19, 2024

@D3Hunter: 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
fast_test_tiprow 3889d53 link true /test fast_test_tiprow

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

@D3Hunter
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Nov 19, 2024

@D3Hunter: 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.

@ti-chi-bot ti-chi-bot bot merged commit ecca340 into pingcap:master Nov 19, 2024
24 of 25 checks passed
@ti-chi-bot
Copy link
Member

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

@D3Hunter D3Hunter deleted the fix-id-jump-in-parallel branch November 19, 2024 12:41
@ti-chi-bot ti-chi-bot bot added the needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. label Dec 3, 2024
@ti-chi-bot
Copy link
Member

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

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Dec 3, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
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 Should cherry pick this PR to release-7.5 branch. needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
4 participants