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
br: pipeline backup schemas #43003
br: pipeline backup schemas #43003
Conversation
Signed-off-by: Leavrth <jianjun.liao@outlook.com>
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
Signed-off-by: Leavrth <jianjun.liao@outlook.com>
br/pkg/backup/client.go
Outdated
ranges, schemas, policies, err := BuildBackupRangeAndSchema(storage, tableFilter, backupTS, isFullBackup, true) | ||
if err != nil { | ||
return nil, nil, nil, errors.Trace(err) | ||
} | ||
// Add keyspace prefix to BackupRequest | ||
for i := range ranges { | ||
start, end := ranges[i].StartKey, ranges[i].EndKey | ||
ranges[i].StartKey, ranges[i].EndKey = storage.GetCodec().EncodeRange(start, end) | ||
} | ||
return ranges, schemas, policies, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: change the ranges with keyspace prefix only when get the ranges from kv storage instead of checkpoint data.
br/pkg/backup/client.go
Outdated
@@ -498,7 +507,7 @@ func BuildBackupRangeAndSchema( | |||
backupTS uint64, | |||
isFullBackup bool, | |||
buildRange bool, | |||
) ([]rtree.Range, *Schemas, []*backuppb.PlacementPolicy, error) { | |||
) ([]rtree.Range, *SchemasV2, []*backuppb.PlacementPolicy, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: only records the size of the schemas for progress in this function
if err != nil { | ||
return nil, nil, nil, errors.Trace(err) | ||
} | ||
|
||
if len(tables) == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: the origin code might have a little mistake: When len(tables) > 0
but all the tables is skipped by table-filter
, so the dbInfo
won't be added into schemas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally LGTM, is it possible to remove the old Schemas
BTW?
Signed-off-by: Leavrth <jianjun.liao@outlook.com>
return nil | ||
} | ||
|
||
schemasNum += 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why schemaNum increasing at the same frequency as tableNum?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
schemaNum
is to record the total number of (dbInfo, tableInfo)
or (dbInfo, nil)
. (equivalent to schemas.Len()
).
tableNum
is to record whether the dbInfo
has records any tableInfo
s. (equivalent to len(tableInfos)
).
now tableNum
has been changed to var hasTable bool
err = schemas.BackupSchemas(ctx, metaWriter, nil, s.mgr.GetStorage(), nil, | ||
s.cfg.StartTS, schemasConcurrency, 0, true, nil) | ||
s.cfg.StartTS, backup.DefaultSchemaConcurrency, 0, true, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concurrency is different now. Is it intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's because the new schemas
need to iterates all tables to get the size, which is repeated in this situation. Therefore, we don't get the size of schemas
.
Besides, we can see the workerpool
in schemas.BackupSchemas
only push the worker
to channel. Only when call ApplyOnErrorGroup
, it would create a new goroutine. So directly use backup.DefaultSchemaConcurrency
is somewhat equivalent to mathutil.Min(backup.DefaultSchemaConcurrency, schemas.Len()))
.
If schemas.Len()
>= backup.DefaultSchemaConcurrency
, it is the same to use backup.DefaultSchemaConcurrency
.
If schemas.Len()
< backup.DefaultSchemaConcurrency
, the new version would create the schemas.Len()
goroutine in total, which is the same as old version. And backup.DefaultSchemaConcurrency - schemas.Len()
more worker struct
add into the channel, which is no effect.
Signed-off-by: Leavrth <jianjun.liao@outlook.com>
/merge |
This pull request has been accepted and is ready to merge. Commit hash: e0e19e5
|
/retest |
1 similar comment
/retest |
Signed-off-by: Leavrth <jianjun.liao@outlook.com>
/retest |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 373705f
|
/retest |
1 similar comment
/retest |
What problem does this PR solve?
Issue Number: close #43002
Problem Summary:
when backup a large cluster, br will loads many table info into memory, which leads to oom.
What is changed and how it works?
pipeline backup schemas
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.