Skip to content
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

optimize: add a EnsureSafeSplitKey in Decider #42056

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pkg/storage/split/decider.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package split
import (
"time"

"github.com/cockroachdb/cockroach/pkg/keys"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/util/syncutil"
)
Expand Down Expand Up @@ -139,7 +140,12 @@ func (d *Decider) MaybeSplitKey(now time.Time) roachpb.Key {
d.mu.Lock()
d.recordLocked(now, 0, nil)
if d.mu.splitFinder != nil && d.mu.splitFinder.Ready(now) {
key = d.mu.splitFinder.Key()
// For example, the data key is /Table/68/1/10. The endkey boundary of the range
// is exactly /Table/68/1/10/0. The previous range does not contain /Table/68/1/10/0,
// the latter one. Range contains. But the scan request sends startKey /Table/68/1/10,
// endKey /Table/68/1/10/0 in the previous range. The key of the put request is /Table/68/1/10/0.
// In the next range, the read and write is separated.
key, _ = keys.EnsureSafeSplitKey(d.mu.splitFinder.Key())
}
d.mu.Unlock()

Expand Down