-
Notifications
You must be signed in to change notification settings - Fork 758
[release-8.5-keyspace] add option to skip rawkv region bound #10535
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
Open
bufferflies
wants to merge
10
commits into
tikv:master
Choose a base branch
from
bufferflies:pr-merge/0c88ce89-skip-rawkv-region-bound
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0ef292c
[release-8.5-keyspace] add option to skip rawkv region bound (#292) (…
zeminzhou 4473520
server/config: keep disable-raw-kv-region-split as json bool
bufferflies 4a19d98
pkg/keyspace: export MakeKeyRanges
bufferflies d2798e3
pkg/keyspace, pd-ctl: restore MakeKeyRanges compatibility
bufferflies bff1863
pkg/keyspace: restore MakeLabelRule compatibility
bufferflies 340c62e
keyspace: derive region bound from key type
bufferflies edcbc90
keyspace: keep full bound fallback without config
bufferflies 68f7c90
server/config: keep legacy keyspace field unmarshal safe
bufferflies 7577827
return table key type if key-type is empty
bufferflies a89d656
fix test
bufferflies 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,7 +38,6 @@ import ( | |
| "github.com/tikv/pd/pkg/storage/kv" | ||
| "github.com/tikv/pd/pkg/utils/etcdutil" | ||
| "github.com/tikv/pd/pkg/utils/keypath" | ||
| "github.com/tikv/pd/pkg/utils/logutil" | ||
| "github.com/tikv/pd/pkg/utils/syncutil" | ||
| "github.com/tikv/pd/pkg/versioninfo/kerneltype" | ||
| ) | ||
|
|
@@ -506,7 +505,8 @@ func (manager *Manager) splitKeyspaceRegion(id uint32, waitRegionSplit bool) (er | |
| }) | ||
|
|
||
| start := time.Now() | ||
| keyspaceRule := MakeLabelRule(id) | ||
| boundType := manager.getRegionBoundType() | ||
|
Member
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. Do we need to prevent dynamically changing the keytype?
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. Yes, later we should persist the key type when we create the keyspace. |
||
| keyspaceRule := buildLabelRule(id, boundType) | ||
| cl, ok := manager.cluster.(interface{ GetRegionLabeler() *labeler.RegionLabeler }) | ||
| if !ok { | ||
| return errors.New("cluster does not support region label") | ||
|
|
@@ -527,11 +527,18 @@ func (manager *Manager) splitKeyspaceRegion(id uint32, waitRegionSplit bool) (er | |
| zap.Error(err), | ||
| ) | ||
| } | ||
| return | ||
| } | ||
| log.Info("added region label for keyspace", | ||
| zap.Uint32("keyspace-id", id), | ||
| zap.Any("label-rule", keyspaceRule), | ||
| zap.Duration("takes", time.Since(start)), | ||
| zap.Stringer("key-type", boundType), | ||
| ) | ||
| }() | ||
|
|
||
| if waitRegionSplit { | ||
| err = manager.waitKeyspaceRegionSplit(id) | ||
| err = manager.waitKeyspaceRegionSplit(id, boundType) | ||
| if err != nil { | ||
| log.Warn("[keyspace] wait region split meets error", | ||
| zap.Uint32("keyspace-id", id), | ||
|
|
@@ -540,16 +547,10 @@ func (manager *Manager) splitKeyspaceRegion(id uint32, waitRegionSplit bool) (er | |
| } | ||
| return err | ||
| } | ||
|
|
||
| log.Info("[keyspace] added region label for keyspace", | ||
| zap.Uint32("keyspace-id", id), | ||
| logutil.ZapRedactString("label-rule", keyspaceRule.String()), | ||
| zap.Duration("takes", time.Since(start)), | ||
| ) | ||
| return | ||
| return nil | ||
| } | ||
|
|
||
| func (manager *Manager) waitKeyspaceRegionSplit(id uint32) error { | ||
| func (manager *Manager) waitKeyspaceRegionSplit(id uint32, boundType regionBoundType) error { | ||
| ticker := time.NewTicker(manager.config.GetCheckRegionSplitInterval()) | ||
| timer := time.NewTimer(manager.config.GetWaitRegionSplitTimeout()) | ||
| defer func() { | ||
|
|
@@ -561,7 +562,7 @@ func (manager *Manager) waitKeyspaceRegionSplit(id uint32) error { | |
| case <-manager.ctx.Done(): | ||
| return errors.New("[keyspace] wait region split canceled") | ||
| case <-ticker.C: | ||
| if manager.CheckKeyspaceRegionBound(id) { | ||
| if manager.hasKeyspaceRegionBound(id, boundType) { | ||
| log.Info("[keyspace] wait region split successfully", zap.Uint32("keyspace-id", id)) | ||
| return nil | ||
| } | ||
|
|
@@ -576,11 +577,31 @@ func (manager *Manager) waitKeyspaceRegionSplit(id uint32) error { | |
|
|
||
| // CheckKeyspaceRegionBound checks whether the keyspace region has been split. | ||
| func (manager *Manager) CheckKeyspaceRegionBound(id uint32) bool { | ||
|
bufferflies marked this conversation as resolved.
|
||
| return manager.hasKeyspaceRegionBound(id, manager.getRegionBoundType()) | ||
| } | ||
|
|
||
| func (manager *Manager) hasKeyspaceRegionBound(id uint32, boundType regionBoundType) bool { | ||
| regionBound := MakeRegionBound(id) | ||
| return manager.checkBound(regionBound.RawLeftBound) && | ||
| manager.checkBound(regionBound.RawRightBound) && | ||
| manager.checkBound(regionBound.TxnLeftBound) && | ||
| manager.checkBound(regionBound.TxnRightBound) | ||
| switch boundType { | ||
| case txnRegionBound: | ||
| return manager.checkBound(regionBound.TxnLeftBound) && | ||
| manager.checkBound(regionBound.TxnRightBound) | ||
| case rawRegionBound: | ||
| return manager.checkBound(regionBound.RawLeftBound) && | ||
| manager.checkBound(regionBound.RawRightBound) | ||
| default: | ||
| return manager.checkBound(regionBound.RawLeftBound) && | ||
| manager.checkBound(regionBound.RawRightBound) && | ||
| manager.checkBound(regionBound.TxnLeftBound) && | ||
| manager.checkBound(regionBound.TxnRightBound) | ||
| } | ||
| } | ||
|
|
||
| func (manager *Manager) getRegionBoundType() regionBoundType { | ||
| if manager.cluster == nil || manager.cluster.GetSharedConfig() == nil { | ||
|
bufferflies marked this conversation as resolved.
|
||
| return allRegionBound | ||
| } | ||
| return keyTypeToRegionBoundType(manager.cluster.GetSharedConfig().GetKeyType()) | ||
| } | ||
|
|
||
| func (manager *Manager) checkBound(key []byte) bool { | ||
|
|
||
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
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.
Why do we need 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.
In the unit test.