Skip to content

Conversation

Leavrth
Copy link
Contributor

@Leavrth Leavrth commented Apr 7, 2025

What problem does this PR solve?

Issue Number: ref #60374

Problem Summary:
BR needs to update the stats meta of the partition.

What changed and how does it work?

Record files based on the physical ID.

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

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/needs-tests-checked size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed do-not-merge/needs-tests-checked labels Apr 7, 2025
Copy link

tiprow bot commented Apr 7, 2025

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

@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 8, 2025
Signed-off-by: Jianjun Liao <[email protected]>
@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 Apr 11, 2025
Copy link

codecov bot commented Apr 21, 2025

Codecov Report

Attention: Patch coverage is 75.38462% with 32 lines in your changes missing coverage. Please review.

Project coverage is 74.9570%. Comparing base (2704b09) to head (e43072a).
Report is 5 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #60423        +/-   ##
================================================
+ Coverage   73.1369%   74.9570%   +1.8200%     
================================================
  Files          1716       1762        +46     
  Lines        475676     483968      +8292     
================================================
+ Hits         347895     362768     +14873     
+ Misses       106410      98491      -7919     
- Partials      21371      22709      +1338     
Flag Coverage Δ
integration 48.8257% <75.3846%> (?)
unit 72.4572% <18.4615%> (+0.0991%) ⬆️

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

Components Coverage Δ
dumpling 52.6553% <ø> (ø)
parser ∅ <ø> (∅)
br 62.3604% <75.3846%> (+14.9232%) ⬆️
🚀 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.

Leavrth added 2 commits April 21, 2025 11:18
Signed-off-by: Jianjun Liao <[email protected]>
Signed-off-by: Jianjun Liao <[email protected]>
}

// GetPartitionByName gets the partition ID from the given tableInfo if its name matches
func GetPartitionByName(tableInfo *model.TableInfo, name ast.CIStr) (int64, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is there no exiting method to get partition by name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Replace it by (*Partition).GetPartitionIDByName and reserve the function to convert the returned result -1 to error.

Copy link
Contributor

@BornChanger BornChanger left a comment

Choose a reason for hiding this comment

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

other part lgtm

Leavrth added 3 commits April 21, 2025 14:37
Signed-off-by: Jianjun Liao <[email protected]>
Signed-off-by: Jianjun Liao <[email protected]>
Signed-off-by: Jianjun Liao <[email protected]>
if err != nil {
return errors.Trace(err)
}
if backupMeta.IsRawKv || backupMeta.IsTxnKv {
Copy link
Contributor

Choose a reason for hiding this comment

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

please make a case (ut or integration) to cover the logic branch.

Leavrth added 2 commits April 22, 2025 13:47
Signed-off-by: Jianjun Liao <[email protected]>
Signed-off-by: Jianjun Liao <[email protected]>
Copy link
Contributor

@3pointer 3pointer 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


codec := mgr.GetStorage().GetCodec()
if len(files) == 0 {
anyFileKey := getAnyFileKeyFromTables(tables)
Copy link
Contributor

Choose a reason for hiding this comment

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

will file.StartKey be nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, getAnyFileKeyFromTables will return a non-nil key.

@ti-chi-bot ti-chi-bot bot added the approved label Apr 22, 2025
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Apr 22, 2025
Leavrth added 2 commits April 22, 2025 17:37
Signed-off-by: Jianjun Liao <[email protected]>
Signed-off-by: Jianjun Liao <[email protected]>
Copy link
Contributor

@Tristan1900 Tristan1900 left a comment

Choose a reason for hiding this comment

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

lgtm!

if fileMap != nil {
if files, ok := fileMap[table.Info.ID]; ok {
table.Files = append(table.Files, files...)
if files, ok := fileMap[table.Info.ID]; ok && len(files) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess on line 443 it's not tableID but physcialID?

fileMap[tableID] = append(fileMap[tableID], file)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

return errors.Trace(err)
}
if statsErr = statsHandler.SaveMetaToStorage(newDefID, count, 0, "br restore", false); statsErr != nil {
log.Error("update stats meta failed", zap.Any("table", tbl.Table), zap.Int64("downstream partition id", newDefID), zap.Error(statsErr))
Copy link
Contributor

Choose a reason for hiding this comment

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

would log entire table be too much details? I'm concerned of log spamming

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

if tableInfo.Partition == nil {
return 0, errors.Errorf("the table %s[id=%d] does not have parition", tableInfo.Name.O, tableInfo.ID)
}
if partID := tableInfo.Partition.GetPartitionIDByName(name.L); partID > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

could this name be empty string? Jus asking

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No

@Leavrth
Copy link
Contributor Author

Leavrth commented Apr 23, 2025

/retest

Copy link

tiprow bot commented Apr 23, 2025

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

Copy link

ti-chi-bot bot commented Apr 23, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 3pointer, BornChanger

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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Apr 23, 2025
Copy link

ti-chi-bot bot commented Apr 23, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-04-22 08:08:29.450046412 +0000 UTC m=+343053.261836781: ☑️ agreed by 3pointer.
  • 2025-04-23 07:53:09.816662501 +0000 UTC m=+428533.628452874: ☑️ agreed by BornChanger.

@Leavrth
Copy link
Contributor Author

Leavrth commented Apr 23, 2025

/ok-to-test

@ti-chi-bot ti-chi-bot bot added the ok-to-test Indicates a PR is ready to be tested. label Apr 23, 2025
@Leavrth
Copy link
Contributor Author

Leavrth commented Apr 23, 2025

/retest

1 similar comment
@Leavrth
Copy link
Contributor Author

Leavrth commented Apr 23, 2025

/retest

@ti-chi-bot ti-chi-bot bot merged commit 5a03265 into pingcap:master Apr 23, 2025
34 checks passed
Kiran01bm pushed a commit to Kiran01bm/tidb that referenced this pull request Apr 29, 2025
Tristan1900 pushed a commit to Tristan1900/tidb that referenced this pull request Jun 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm ok-to-test Indicates a PR is ready to be tested. 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
Development

Successfully merging this pull request may close these issues.

4 participants