-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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: PiTR table filter online support #59281
base: master
Are you sure you want to change the base?
Conversation
Skipping CI for Draft Pull Request. |
Hi @Tristan1900. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with 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. |
20c175b
to
381e01b
Compare
c92fc12
to
7309304
Compare
7309304
to
0d4d25e
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #59281 +/- ##
================================================
+ Coverage 73.1368% 74.3109% +1.1740%
================================================
Files 1707 1754 +47
Lines 471602 479881 +8279
================================================
+ Hits 344915 356604 +11689
+ Misses 105487 100672 -4815
- Partials 21200 22605 +1405
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
05b0129
to
ac16ebe
Compare
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.
rest LGTM
br/pkg/stream/table_history.go
Outdated
// MarkTableDeleted marks a table as deleted | ||
func (info *LogBackupTableHistoryManager) MarkTableDeleted(tableId int64) { | ||
info.deletedTables[tableId] = struct{}{} | ||
} | ||
|
||
// MarkTablesDeleted marks multiple tables as deleted | ||
func (info *LogBackupTableHistoryManager) MarkTablesDeleted(tableIds []int64) { | ||
for _, tableId := range tableIds { | ||
info.MarkTableDeleted(tableId) | ||
} | ||
} | ||
|
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.
// MarkTableDeleted marks a table as deleted | |
func (info *LogBackupTableHistoryManager) MarkTableDeleted(tableId int64) { | |
info.deletedTables[tableId] = struct{}{} | |
} | |
// MarkTablesDeleted marks multiple tables as deleted | |
func (info *LogBackupTableHistoryManager) MarkTablesDeleted(tableIds []int64) { | |
for _, tableId := range tableIds { | |
info.MarkTableDeleted(tableId) | |
} | |
} | |
// MarkTablesDeleted marks multiple tables as deleted | |
func (info *LogBackupTableHistoryManager) MarkTablesDeleted(tableIds []int64) { | |
for _, tableId := range tableIds { | |
info.deletedTables[tableId] = struct{}{} | |
} | |
} | |
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.
It seems it is only used by unit tests
@@ -129,7 +143,7 @@ func (tm *TableMappingManager) ParseMetaKvAndUpdateIdMapping(e *kv.Entry, cf str | |||
return errors.Trace(err) | |||
} | |||
if value != nil { | |||
return tm.parseTableValueAndUpdateIdMapping(dbID, value) | |||
return tm.parseTableValueAndUpdateIdMapping(dbID, value, collector) |
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.
should here return nil
if value == 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.
yeah it fall through to the end of this method and return nil
br/pkg/restore/log_client/client.go
Outdated
@@ -1413,6 +1413,11 @@ func (rc *LogClient) restoreAndRewriteMetaKvEntries( | |||
} else if newEntry == nil { | |||
continue | |||
} | |||
// sanity check key will never to nil, otherwise will write invalid format data to TiKV | |||
if newEntry.Key == 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.
we can use if len(newEntry.Key) == 0
to cover nil
and []byte{}
.
br/pkg/task/restore_raw.go
Outdated
@@ -112,7 +112,8 @@ func RunRestoreRaw(c context.Context, g glue.Glue, cmdName string, cfg *RestoreR | |||
return errors.Trace(err) | |||
} | |||
reader := metautil.NewMetaReader(backupMeta, s, &cfg.CipherInfo) | |||
if err = client.LoadSchemaIfNeededAndInitClient(c, backupMeta, u, reader, true, cfg.StartKey, cfg.EndKey); err != nil { | |||
if err = client.LoadSchemaIfNeededAndInitClient(c, backupMeta, u, reader, true, cfg.StartKey, cfg.EndKey, | |||
cfg.ExplicitFilter, isFullRestore(cmdName)); err != 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.
we use ./br restore raw
, so the cmdName is always Raw Restore
. So is it OK to use isFullRestore("Raw Restore")
here?
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.
isFullRestore("Raw Restore") can work and will return false. I made the change cuz original code only set the initFullCLusterRestore under isFullRestore so raw will never enter
if isFullRestore(cmdName) {
if client.NeedCheckFreshCluster(cfg.ExplicitFilter, checkpointFirstRun) {
if err = client.CheckTargetClusterFresh(ctx); err != nil {
return errors.Trace(err)
}
}
// todo: move this check into InitFullClusterRestore, we should move restore config into a separate package
// to avoid import cycle problem which we won't do it in this pr, then refactor this
//
// if it's point restore and reached here, then cmdName=FullRestoreCmd and len(cfg.FullBackupStorage) > 0
if cfg.WithSysTable {
client.InitFullClusterRestore(cfg.ExplicitFilter)
}
} else if client.IsFull() && checkpointFirstRun && cfg.CheckRequirements {
if err := checkTableExistence(ctx, mgr, tables); err != nil {
canRestoreSchedulers = true
return errors.Trace(err)
}
}
br/pkg/task/restore.go
Outdated
ctx context.Context, | ||
g glue.Glue, | ||
cfg *SnapshotRestoreConfig, | ||
domain *domain.Domain, |
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.
unused parameter
// | ||
// if it's point restore and reached here, then cmdName=FullRestoreCmd and len(cfg.FullBackupStorage) > 0 | ||
if cfg.WithSysTable { | ||
client.InitFullClusterRestore(cfg.ExplicitFilter) |
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.
cfg.WithSysTable
is lost now. We should also check it in client.InitFullClusterRestore
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.
nice catch, added!
br/pkg/task/restore.go
Outdated
} | ||
log.Info("checkpoint status in restore", zap.Bool("enabled", cfg.UseCheckpoint), zap.Bool("exists", cpEnabledAndExists)) | ||
if err := checkMandatoryClusterRequirements(client, cfg, cpEnabledAndExists, cmdName); err != nil { | ||
return errors.Trace(err) | ||
} | ||
if err = VerifyDBAndTableInBackup(client.GetDatabases(), cfg.RestoreConfig); err != 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.
VerifyDBAndTableInBackup
is already in the checkMandatoryClusterRequirements
. We can remove it.
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.
oh right, it was due to merge conflicts.
br/pkg/task/restore.go
Outdated
|
||
// update table mapping manager with new table ids if pitr | ||
if isPiTR { | ||
cfg.tableMappingManager.UpdateDownstreamIds(tables, client.GetDomain()) |
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.
UpdateDownstreamIds
doesn't need to get tableInfo from domain because createdTables
already keeps them. See
tidb/br/pkg/restore/snap_client/client.go
Line 917 in f8f667e
ct := &CreatedTable{ |
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.
Besides, tableMappingManager.MergeBaseDBReplace(dbReplaces)
in pkg/task/stream.go
seems duplicated?
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Leavrth The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
d5993d6
to
f9f47fe
Compare
Signed-off-by: Wenqi Mou <[email protected]>
Signed-off-by: Wenqi Mou <[email protected]>
Signed-off-by: Wenqi Mou <[email protected]>
Signed-off-by: Wenqi Mou <[email protected]>
Signed-off-by: Wenqi Mou <[email protected]>
Signed-off-by: Wenqi Mou <[email protected]>
f9f47fe
to
ff865e7
Compare
@Tristan1900: The following tests failed, say
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. |
What problem does this PR solve?
Issue Number: close #59280
Problem Summary:
What changed and how does it work?
Make sure when user wants to use PiTR table filter to restore to an online cluster, the flag --online is specified.
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.