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

presplit: send split_region request to PD instead of TiKV #1474

Open
AndreMouche opened this issue Oct 14, 2024 · 0 comments
Open

presplit: send split_region request to PD instead of TiKV #1474

AndreMouche opened this issue Oct 14, 2024 · 0 comments

Comments

@AndreMouche
Copy link
Member

When we find a transaction try to insert into a region with more than 100000 items, it will do split the region to avoid too much write workload into a single region:

preSplitDetectThresholdVal := atomic.LoadUint32(&preSplitDetectThreshold)
for _, group := range groups {
if uint32(group.mutations.Len()) >= preSplitDetectThresholdVal {
logutil.BgLogger().Info("2PC detect large amount of mutations on a single region",
zap.Uint64("region", group.region.GetID()),
zap.Int("mutations count", group.mutations.Len()),
zap.Uint64("startTS", c.startTS))
if c.preSplitRegion(bo.GetCtx(), group) {
didPreSplit = true
}
}
}

However, here we send split request to TiKV.

req := tikvrpc.NewRequest(tikvrpc.CmdSplitRegion, &kvrpcpb.SplitRegionRequest{
SplitKeys: batch.Keys,
}, kvrpcpb.Context{
Priority: kvrpcpb.CommandPri_Normal,
RequestSource: util.RequestSourceFromCtx(bo.GetCtx()),
})

I think we should send the split-request to PD since PD will only apply one operator to a region each time, which will help use to avoid the issue(tikv/tikv#12410) caused by two operators run on the same region concurrently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant