[connect/tidb] Split key ranges by TiKV region via FLIP-27 enumerator - #4508
Open
lifulong wants to merge 1 commit into
Open
Conversation
lifulong
force-pushed
the
split_key_ranges_by_tike_region_to_avoid_auto_increament_skew
branch
2 times, most recently
from
August 17, 2026 11:11
7002d48 to
07990aa
Compare
lifulong
force-pushed
the
split_key_ranges_by_tike_region_to_avoid_auto_increament_skew
branch
from
August 18, 2026 07:04
07990aa to
0632314
Compare
Author
|
@leonardBang @GOODBOY008 @lvyanquan can you help review this change? |
lifulong
force-pushed
the
split_key_ranges_by_tike_region_to_avoid_auto_increament_skew
branch
from
August 18, 2026 08:09
0632314 to
10d3206
Compare
lifulong
force-pushed
the
split_key_ranges_by_tike_region_to_avoid_auto_increament_skew
branch
from
August 18, 2026 08:14
10d3206 to
f5895fa
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What is the purpose of this pull request?
TiDB CDC used to split a table by evenly partitioning the entire
longhandle space (Long.MIN_VALUE~Long.MAX_VALUE).For clustered
AUTO_INCREMENTprimary keys, real handles only occupy a tiny slice of that space. With parallelism 8, almost all rows land on a single subtask, which then OOMs duringKVClient.scan.This change assigns each reader a contiguous chunk of real TiKV regions covering the table, so snapshot and incremental CDC scale with region count instead of the theoretical
longdomain.Region topology is discovered once by a FLIP-27 enumerator. Each parallel
SourceFunction.open()used to query PD independently; if region split/merge happened while tasks started minutes apart, assigned key ranges could overlap (duplicate CDC) or leave gaps (lost data). The enumerator snapshots region boundaries, assigns one contiguousKeyRangeper reader, and restore reuses checkpointed splits instead of rediscovering PD.Runtime region split/merge is still handled by
CDCClientinside the assigned key range. That only remaps physical regions onto a frozen key-space ownership and does not re-partition work across readers.Brief change log
TiKVSource(TiKVSourceEnumerator+TiKVSourceReader)RangeSplitter.splitRangeByRegion, clips/sorts/merges contiguous region chunks, and assigns oneTiKVKeyRangeSplitper subtaskresolvedTsis stored on the splitSourceProvider; DataStreamTiDBSource.builder().build()now returnsTiKVSource(useenv.fromSource)TiKVRichParallelSourceFunction/buildSourceFunction()Verifying this change
TableKeyRangeUtilsTestandTiKVKeyRangeSplitSerializerTestDocumentation
fromSource)Was generative AI tooling used to co-author this PR?