Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

analyze: analyze table after restore #605

Merged
merged 23 commits into from
Nov 26, 2020
Merged

Conversation

3pointer
Copy link
Collaborator

What problem does this PR solve?

close #598

What is changed and how it works?

  1. backup stats json in backup meta.
  2. restore stats after validate checksum.

Check List

Tests

  • Manual test (add detailed scripts or steps below)

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation

Release Note

  • Fix the issue that didn't analyze table after restoration.

@3pointer 3pointer marked this pull request as ready for review November 25, 2020 04:49
@3pointer
Copy link
Collaborator Author

/rebuild

1 similar comment
@zhouqiang-cl
Copy link
Contributor

/rebuild

@3pointer
Copy link
Collaborator Author

/rebuild

1 similar comment
@3pointer
Copy link
Collaborator Author

/rebuild

pkg/backup/client.go Outdated Show resolved Hide resolved
@@ -56,8 +55,6 @@ func NewBackupCommand() *cobra.Command {

// Do not run ddl worker in BR.
ddl.RunWorker = false
// Do not run stat worker in BR.
session.DisableStats4Test()
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we disable the stats loop after we have dumped all JSONTables?

Copy link
Collaborator Author

@3pointer 3pointer Nov 25, 2020

Choose a reason for hiding this comment

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

when we reached here, we have a domain already. so it seems we can not touch the statsLease any more, https://github.com/pingcap/tidb/blob/e136429d8dc5d70f43cd3f94179b0b9f47595097/session/tidb.go#L68

3pointer and others added 2 commits November 25, 2020 16:37
@3pointer
Copy link
Collaborator Author

/rebuild

@glorv
Copy link
Collaborator

glorv commented Nov 25, 2020

/run-all-tests

@glorv
Copy link
Collaborator

glorv commented Nov 25, 2020

/build

Copy link
Collaborator

@kennytm kennytm left a comment

Choose a reason for hiding this comment

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

please add a test involving restoring from an older archive where the stats are missing (nil).

(perhaps add a flag like br backup --stats=false too to simplify testing)

@3pointer
Copy link
Collaborator Author

/rebuild

for _, t := range tables {
log.Info("entering", zap.Int64("table ID", t.Table.ID))
manager[t.Table.ID] = true
manager.lock.Lock()
Copy link
Collaborator

Choose a reason for hiding this comment

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

move this lock outsize the for loop

for _, t := range tables {
if !manager[t.Table.ID] {
manager.lock.Lock()
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

for _, t := range tables {
ids = append(ids, t.Table.ID)
}
for id, contains := range manager {
for id, contains := range manager.m {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Read option should be protected by lock

@3pointer
Copy link
Collaborator Author

please add a test involving restoring from an older archive where the stats are missing (nil).

(perhaps add a flag like br backup --stats=false too to simplify testing)

Done, PTAL

pkg/task/backup.go Outdated Show resolved Hide resolved
Copy link
Contributor

@lichunzhu lichunzhu left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot ti-srebot added the status/LGT1 LGTM1 label Nov 26, 2020
@3pointer
Copy link
Collaborator Author

/rebuild

@glorv
Copy link
Collaborator

glorv commented Nov 26, 2020

/build

1 similar comment
@glorv
Copy link
Collaborator

glorv commented Nov 26, 2020

/build

Copy link
Collaborator

@kennytm kennytm 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

pkg/restore/batcher_test.go Show resolved Hide resolved
pkg/restore/batcher_test.go Show resolved Hide resolved
pkg/restore/client.go Outdated Show resolved Hide resolved
@kennytm
Copy link
Collaborator

kennytm commented Nov 26, 2020

LGTM

@ti-srebot ti-srebot removed the status/LGT1 LGTM1 label Nov 26, 2020
@ti-srebot ti-srebot added the status/LGT2 LGTM2 label Nov 26, 2020
@glorv
Copy link
Collaborator

glorv commented Nov 26, 2020

/merge

@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot ti-srebot merged commit 1a7a2f3 into pingcap:master Nov 26, 2020
@ti-srebot
Copy link
Contributor

cherry pick to release-4.0 failed

lichunzhu pushed a commit to lichunzhu/br that referenced this pull request Nov 26, 2020
overvenus pushed a commit that referenced this pull request Nov 27, 2020
* cherry-pick #610
* cherry-pick #605
* fix: backup will skip empty databases. (#560)

Co-authored-by: 3pointer <luancheng@pingcap.com>
Co-authored-by: tangwz <tangwz.com@gmail.com>
Co-authored-by: 山岚 <36239017+YuJuncen@users.noreply.github.com>
Co-authored-by: kennytm <kennytm@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Analyze database after restore
6 participants