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: finer granularity for tidb backend finished bytes #39318

Merged
merged 13 commits into from
Nov 23, 2022

Conversation

lance6716
Copy link
Contributor

@lance6716 lance6716 commented Nov 22, 2022

Signed-off-by: lance6716 lance6716@gmail.com

What problem does this PR solve?

Issue Number: close #xxx

Problem Summary:

I still use the old Lightning.Status to get the finished bytes and total bytes. For TiDB backend, finished bytes will be counted after write to TiDB, and also will recover from checkpoints

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

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

Signed-off-by: lance6716 <lance6716@gmail.com>
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Nov 22, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • D3Hunter
  • okJiang

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 22, 2022
@lance6716
Copy link
Contributor Author

/cc @D3Hunter @okJiang

I'm working on it

Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
@ti-chi-bot ti-chi-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 23, 2022
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
@lance6716 lance6716 changed the title [WIP]lightning: recover some metrics from checkpoint lightning: finer granularity for tidb backend finished bytes Nov 23, 2022
@ti-chi-bot ti-chi-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 23, 2022
@lance6716
Copy link
Contributor Author

/run-integration-br-tests

@lance6716
Copy link
Contributor Author

/run-integration-br-tests

@@ -406,6 +406,11 @@ func (tr *TableRestore) restoreEngine(
if err != nil {
return closedEngine, errors.Trace(err)
}
if rc.status != nil && rc.status.backend == config.BackendTiDB {
for _, chunk := range cp.Chunks {
rc.status.FinishedFileSize.Add(chunk.Chunk.EndOffset)
Copy link
Contributor

Choose a reason for hiding this comment

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

should it be chunk.Chunk.EndOffset-chunk.Key.Offset, in case of strict format where chunk.Key.Offset is not 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.

I'm not familiar with strict format, can you give some reference to the behaviour?

I think you want to keep a property that the value of FinishedFileSize.Add should be same no matter it's processed without failure or recovered from checkpoint?

Copy link
Contributor Author

@lance6716 lance6716 Nov 23, 2022

Choose a reason for hiding this comment

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

OK I guess the strict mode will split a file into many chunks, the split position is written in Key.Offset

@@ -475,6 +480,9 @@ func (tr *TableRestore) restoreEngine(

// Restore table data
for chunkIndex, chunk := range cp.Chunks {
if rc.status != nil && rc.status.backend == config.BackendTiDB {
rc.status.FinishedFileSize.Add(chunk.Chunk.Offset)
Copy link
Contributor

Choose a reason for hiding this comment

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

should it be chunk.Chunk.Offset - chunk.Key.Offset to count previous imported data

@@ -475,6 +480,9 @@ func (tr *TableRestore) restoreEngine(

// Restore table data
for chunkIndex, chunk := range cp.Chunks {
if rc.status != nil && rc.status.backend == config.BackendTiDB {
rc.status.FinishedFileSize.Add(chunk.Chunk.Offset)
Copy link
Member

Choose a reason for hiding this comment

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

seems that not restore completedly here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

here I want to recover FinishedFileSize from checkpoint, the restore process of current run is not started

br/pkg/lightning/restore/table_restore.go Outdated Show resolved Hide resolved
Signed-off-by: lance6716 <lance6716@gmail.com>
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Nov 23, 2022
@lance6716
Copy link
Contributor Author

/run-integration-br-tests

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Nov 23, 2022
@okJiang
Copy link
Member

okJiang commented Nov 23, 2022

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 6250609

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Nov 23, 2022
@ti-chi-bot ti-chi-bot merged commit f50113f into pingcap:master Nov 23, 2022
@sre-bot
Copy link
Contributor

sre-bot commented Nov 23, 2022

TiDB MergeCI notify

✅ Well Done! New fixed [2] after this pr merged.

CI Name Result Duration Compare with Parent commit
idc-jenkins-ci/integration-cdc-test 🔴 failed 1, success 38, total 39 20 min Existing failure
idc-jenkins-ci-tidb/sqllogic-test-2 🔴 failed 6, success 22, total 28 12 min Existing failure
idc-jenkins-ci-tidb/mybatis-test 🔴 failed 1, success 0, total 1 11 min Existing failure
idc-jenkins-ci-tidb/integration-ddl-test 🔴 failed 1, success 5, total 6 4 min 33 sec Existing failure
idc-jenkins-ci-tidb/integration-common-test ✅ all 17 tests passed 18 min Fixed
idc-jenkins-ci-tidb/common-test ✅ all 11 tests passed 14 min Fixed
idc-jenkins-ci-tidb/tics-test 🟢 all 1 tests passed 6 min 12 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-1 🟢 all 26 tests passed 5 min 13 sec Existing passed
idc-jenkins-ci-tidb/integration-compatibility-test 🟢 all 1 tests passed 2 min 57 sec Existing passed
idc-jenkins-ci-tidb/plugin-test 🟢 build success, plugin test success 4min Existing passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants