Skip to content

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

Open
@AndreMouche

Description

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.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions