This repository has been archived by the owner on Jul 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 101
analyze: analyze table after restore #605
Merged
Merged
Changes from 19 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
02c56d7
analyze: analyze table after restore
3pointer 6c65aca
update kvproto & add test
3pointer 29922bc
fix build
3pointer d18a920
fix go mod
3pointer 979f921
update tidb to complie
3pointer 10cc69e
Merge branch 'master' into analyze
3pointer eeb34ec
fix test
3pointer ce079e4
fix test
3pointer 53640f0
fix build
3pointer 2d5280b
fix ci
3pointer 93dcb1a
Update pkg/backup/client.go
3pointer a83cd17
Merge branch 'master' into analyze
3pointer 90f2340
fix ci failed
3pointer 8475315
address comment
3pointer 3ecfb1f
fix buid
3pointer a2ccf2b
address comment
3pointer 64db129
fix ci
3pointer 9c91339
add test for old backup
3pointer 80be6d4
update comments
3pointer 8c986b2
address comment
3pointer 5440134
address comment
3pointer 5a00a7b
address comment
3pointer e8a513a
Merge branch 'master' into analyze
3pointer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,52 +68,62 @@ func newDrySender() *drySender { | |
} | ||
} | ||
|
||
type recordCurrentTableManager map[int64]bool | ||
type recordCurrentTableManager struct { | ||
lock sync.Mutex | ||
m map[int64]bool | ||
} | ||
|
||
func (manager recordCurrentTableManager) Close(ctx context.Context) { | ||
if len(manager) > 0 { | ||
func (manager *recordCurrentTableManager) Close(ctx context.Context) { | ||
if len(manager.m) > 0 { | ||
kennytm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
log.Panic("When closing, there are still some tables doesn't be sent", | ||
zap.Any("tables", manager)) | ||
zap.Any("tables", manager.m)) | ||
} | ||
} | ||
|
||
func newMockManager() recordCurrentTableManager { | ||
return make(recordCurrentTableManager) | ||
func newMockManager() *recordCurrentTableManager { | ||
return &recordCurrentTableManager{ | ||
m: make(map[int64]bool), | ||
} | ||
} | ||
|
||
func (manager recordCurrentTableManager) Enter(_ context.Context, tables []restore.CreatedTable) error { | ||
func (manager *recordCurrentTableManager) Enter(_ context.Context, tables []restore.CreatedTable) error { | ||
for _, t := range tables { | ||
log.Info("entering", zap.Int64("table ID", t.Table.ID)) | ||
manager[t.Table.ID] = true | ||
manager.lock.Lock() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move this lock outsize the for loop |
||
manager.m[t.Table.ID] = true | ||
manager.lock.Unlock() | ||
} | ||
return nil | ||
} | ||
|
||
func (manager recordCurrentTableManager) Leave(_ context.Context, tables []restore.CreatedTable) error { | ||
func (manager *recordCurrentTableManager) Leave(_ context.Context, tables []restore.CreatedTable) error { | ||
for _, t := range tables { | ||
if !manager[t.Table.ID] { | ||
manager.lock.Lock() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
if !manager.m[t.Table.ID] { | ||
manager.lock.Unlock() | ||
return errors.Errorf("Table %d is removed before added", t.Table.ID) | ||
lichunzhu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
log.Info("leaving", zap.Int64("table ID", t.Table.ID)) | ||
delete(manager, t.Table.ID) | ||
delete(manager.m, t.Table.ID) | ||
manager.lock.Unlock() | ||
} | ||
return nil | ||
} | ||
|
||
func (manager recordCurrentTableManager) Has(tables ...restore.TableWithRange) bool { | ||
func (manager *recordCurrentTableManager) Has(tables ...restore.TableWithRange) bool { | ||
ids := make([]int64, 0, len(tables)) | ||
currentIDs := make([]int64, 0, len(manager)) | ||
currentIDs := make([]int64, 0, len(manager.m)) | ||
kennytm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for _, t := range tables { | ||
ids = append(ids, t.Table.ID) | ||
} | ||
for id, contains := range manager { | ||
for id, contains := range manager.m { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Read option should be protected by lock |
||
if contains { | ||
currentIDs = append(currentIDs, id) | ||
} | ||
} | ||
log.Info("testing", zap.Int64s("should has ID", ids), zap.Int64s("has ID", currentIDs)) | ||
for _, i := range ids { | ||
if !manager[i] { | ||
if !manager.m[i] { | ||
return false | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
can we disable the stats loop after we have dumped all JSONTables?
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.
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