Skip to content

fix(bigtable): avoid emitting empty open range (K, K\0) in RowSetUtil - #15013

Merged
igorbernstein2 merged 4 commits into
mainfrom
fix-rowsetutil-empty-open-range
Nov 17, 2026
Merged

igorbernstein2 merged 4 commits into
mainfrom
fix-rowsetutil-empty-open-range

Conversation

@igorbernstein2

@igorbernstein2 igorbernstein2 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

In unsigned lexicographical byte order, K\0 (K.concat(ByteString.copyFrom(new byte[] {0}))) is the immediate successor of K, so:

  • An open start bound (K represents the exact same lower bound as a closed start bound [K\0.
  • A closed end bound K] represents the exact same exclusive upper bound as an open end bound K\0).

Previously, RowSetUtil.StartPoint and RowSetUtil.EndPoint compared (value, isClosed) as tuples without normalizing discrete ByteString bounds, causing truncateRange, eraseLargeRow, and shard to emit empty open ranges (K, K\0) which the Cloud Bigtable server rejects with a non-retryable INVALID_ARGUMENT: Error in field 'row_ranges' : start_key must be less than end_key.

Changes

  • Pre-computed canonical half-open bounds (effectiveKey on StartPoint and effectiveLimit on EndPoint) and added isAtOrAfter / isBeforeOrAt bound predicates.
  • Simplified eraseLargeRow to reuse truncateRange (removing the duplicate splitOnLargeRowKey implementation) and updated truncateRange and shard to use StartPoint and EndPoint predicates consistently.
  • Fixed RowSetUtil.shard to buffer split remainders per splitPoint before prepending them back to ranges, preventing an early break when sharding overlapping ranges.
  • Added unit tests in RowSetUtilTest covering eraseLargeRow, erase (forward and reverse), and shard for (K, K\0) boundary and overlapping range cases.

@igorbernstein2
igorbernstein2 requested review from a team as code owners November 13, 2026 22:43

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a helper method isEmptyOpenRange to identify empty open ranges of the form (key, key\u0000) and uses it to correctly exclude or skip these ranges during truncation, splitting, and sharding in RowSetUtil. It also adds corresponding unit tests. A review comment suggests optimizing isEmptyOpenRange to avoid object allocations in hot paths by checking the size, prefix, and trailing byte directly instead of using concat.

@igorbernstein2
igorbernstein2 force-pushed the fix-rowsetutil-empty-open-range branch from a2c0fa9 to 5f1b315 Compare November 16, 2026 16:46
@igorbernstein2 igorbernstein2 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 17, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 17, 2026
@igorbernstein2
igorbernstein2 enabled auto-merge (squash) November 17, 2026 15:06
@igorbernstein2
igorbernstein2 merged commit 9bdd5b8 into main Nov 17, 2026
207 of 208 checks passed
@igorbernstein2
igorbernstein2 deleted the fix-rowsetutil-empty-open-range branch November 17, 2026 15:42
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.

3 participants