-
Notifications
You must be signed in to change notification settings - Fork 6.2k
keyspace: gc delete range #40639
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
Merged
Merged
keyspace: gc delete range #40639
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
1711424
add keyspace drop table logic
ystaticy 3752de0
add keyspace drop table logic
ystaticy 9534706
fix condition of keyspace
ystaticy ede6068
Merge remote-tracking branch 'origin/master' into keyspace_gc
ystaticy 7fac684
fix etcdcli in ServerInformationPath
ystaticy 168a9b2
skip doGCPlacementRules when keyspace_name is set
ystaticy 5c497c8
Merge branch 'master' into keyspace_gc
ystaticy 216b196
remove empty line
ystaticy 44ce5e2
Merge branch 'master' into keyspace_gc
ystaticy 51169ba
Merge branch 'master' into keyspace_gc
ystaticy fa2e0d5
Merge branch 'master' into keyspace_gc
ystaticy e36f591
fix conditiosn
ystaticy ddd49a9
close etcdcli
ystaticy b254cfe
add comments
ystaticy bc2a66e
add comments
ystaticy a7742a3
Merge branch 'master' into keyspace_gc
ystaticy 6de13aa
add comments
ystaticy 5fb78da
Merge branch 'keyspace_gc' of github.com:ystaticy/tidb into keyspace_gc
ystaticy f54b9c9
Merge branch 'master' into keyspace_gc
ystaticy f230556
Merge branch 'master' into keyspace_gc
ystaticy 9ffe54f
add func to print log when gc safepoint is too early
ystaticy 8702daa
Merge branch 'keyspace_gc' of github.com:ystaticy/tidb into keyspace_gc
ystaticy 5d32161
add uuid
ystaticy 790651a
add comments
ystaticy 29fd722
fix grammar
ystaticy 1bf9285
fix grammar
ystaticy 0c1cb16
add comnments
ystaticy af0df85
fix comnments
ystaticy 7cbdbc6
Merge branch 'master' into keyspace_gc
ti-chi-bot 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -95,12 +95,18 @@ var ErrPrometheusAddrIsNotSet = dbterror.ClassDomain.NewStd(errno.ErrPrometheusA | |
|
|
||
| // InfoSyncer stores server info to etcd when the tidb-server starts and delete when tidb-server shuts down. | ||
| type InfoSyncer struct { | ||
| etcdCli *clientv3.Client | ||
| info *ServerInfo | ||
| serverInfoPath string | ||
| minStartTS uint64 | ||
| minStartTSPath string | ||
| managerMu struct { | ||
| // `etcdClient` must be used when keyspace is not set, or when the logic to each etcd path needs to be separated by keyspace. | ||
| etcdCli *clientv3.Client | ||
| // `unprefixedEtcdCli` will never set the etcd namespace prefix by keyspace. | ||
| // It is only used in storeMinStartTS and RemoveMinStartTS now. | ||
| // It must be used when the etcd path isn't needed to separate by keyspace. | ||
| // See keyspace RFC: https://github.com/pingcap/tidb/pull/39685 | ||
| unprefixedEtcdCli *clientv3.Client | ||
|
Contributor
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. Better also add comments for it like in
Contributor
Author
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. I added new comments here. |
||
| info *ServerInfo | ||
| serverInfoPath string | ||
| minStartTS uint64 | ||
| minStartTSPath string | ||
| managerMu struct { | ||
| mu sync.RWMutex | ||
| util2.SessionManager | ||
| } | ||
|
|
@@ -180,12 +186,13 @@ func setGlobalInfoSyncer(is *InfoSyncer) { | |
| } | ||
|
|
||
| // GlobalInfoSyncerInit return a new InfoSyncer. It is exported for testing. | ||
| func GlobalInfoSyncerInit(ctx context.Context, id string, serverIDGetter func() uint64, etcdCli *clientv3.Client, skipRegisterToDashBoard bool) (*InfoSyncer, error) { | ||
| func GlobalInfoSyncerInit(ctx context.Context, id string, serverIDGetter func() uint64, etcdCli *clientv3.Client, unprefixedEtcdCli *clientv3.Client, skipRegisterToDashBoard bool) (*InfoSyncer, error) { | ||
| is := &InfoSyncer{ | ||
| etcdCli: etcdCli, | ||
| info: getServerInfo(id, serverIDGetter), | ||
| serverInfoPath: fmt.Sprintf("%s/%s", ServerInformationPath, id), | ||
| minStartTSPath: fmt.Sprintf("%s/%s", ServerMinStartTSPath, id), | ||
| etcdCli: etcdCli, | ||
| unprefixedEtcdCli: unprefixedEtcdCli, | ||
| info: getServerInfo(id, serverIDGetter), | ||
| serverInfoPath: fmt.Sprintf("%s/%s", ServerInformationPath, id), | ||
| minStartTSPath: fmt.Sprintf("%s/%s", ServerMinStartTSPath, id), | ||
| } | ||
| err := is.init(ctx, skipRegisterToDashBoard) | ||
| if err != nil { | ||
|
|
@@ -721,20 +728,20 @@ func (is *InfoSyncer) GetMinStartTS() uint64 { | |
|
|
||
| // storeMinStartTS stores self server min start timestamp to etcd. | ||
| func (is *InfoSyncer) storeMinStartTS(ctx context.Context) error { | ||
| if is.etcdCli == nil { | ||
| if is.unprefixedEtcdCli == nil { | ||
| return nil | ||
| } | ||
| return util.PutKVToEtcd(ctx, is.etcdCli, keyOpDefaultRetryCnt, is.minStartTSPath, | ||
| return util.PutKVToEtcd(ctx, is.unprefixedEtcdCli, keyOpDefaultRetryCnt, is.minStartTSPath, | ||
| strconv.FormatUint(is.minStartTS, 10), | ||
| clientv3.WithLease(is.session.Lease())) | ||
| } | ||
|
|
||
| // RemoveMinStartTS removes self server min start timestamp from etcd. | ||
| func (is *InfoSyncer) RemoveMinStartTS() { | ||
| if is.etcdCli == nil { | ||
| if is.unprefixedEtcdCli == nil { | ||
| return | ||
| } | ||
| err := util.DeleteKeyFromEtcd(is.minStartTSPath, is.etcdCli, keyOpDefaultRetryCnt, keyOpDefaultTimeout) | ||
| err := util.DeleteKeyFromEtcd(is.minStartTSPath, is.unprefixedEtcdCli, keyOpDefaultRetryCnt, keyOpDefaultTimeout) | ||
| if err != nil { | ||
| logutil.BgLogger().Error("remove minStartTS failed", zap.Error(err)) | ||
| } | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.