Skip to content

Fix off-by-one in split_chunk upper bound - #10342

Open
JoongHyuk-Shin wants to merge 1 commit into
timescale:mainfrom
JoongHyuk-Shin:fix/split-chunk-upper-bound
Open

Fix off-by-one in split_chunk upper bound#10342
JoongHyuk-Shin wants to merge 1 commit into
timescale:mainfrom
JoongHyuk-Shin:fix/split-chunk-upper-bound

Conversation

@JoongHyuk-Shin

Copy link
Copy Markdown
Contributor

split_chunk() splits a chunk [start, end) into [start, split_at) and [split_at, end). Per the invariant documented in the code, both resulting ranges must have length at least 1, so the valid split points are [start + 1, end - 1].

The lower bound was correct, but the upper bound required the right range to have length at least 2. This rejected split_at = end - 1 (a valid length-1 right range) and made a chunk of width 2 unsplittable via an explicit split_at, even though the default midpoint path picks and accepts that same point for a width-2 chunk.

Allow split points up to end - 1 so the bounds are symmetric and match the documented invariant. Empty-range splits remain rejected.

@github-actions

Copy link
Copy Markdown

@melihmutlu, @pnthao: please review this pull request.

Powered by pull-review

@JoongHyuk-Shin
JoongHyuk-Shin force-pushed the fix/split-chunk-upper-bound branch from ae3ab45 to 3db55bd Compare July 28, 2026 09:19
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

split_chunk() splits a chunk [start, end) into [start, split_at) and
[split_at, end). Per the invariant documented in the code, both
resulting ranges must have length at least 1, so the valid split points
are [start + 1, end - 1].

The lower bound was correct, but the upper bound required the right
range to have length at least 2. This rejected split_at = end - 1 (a
valid length-1 right range) and made a chunk of width 2 unsplittable via
an explicit split_at, even though the default midpoint path picks and
accepts that same point for a width-2 chunk.

Allow split points up to end - 1 so the bounds are symmetric and match
the documented invariant. Empty-range splits remain rejected.
@JoongHyuk-Shin
JoongHyuk-Shin force-pushed the fix/split-chunk-upper-bound branch from 3db55bd to 42667ca Compare August 1, 2026 03:10
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

Successfully merging this pull request may close these issues.

1 participant