Skip to content

fix(table): keep generated snapshot IDs non-negative - #1619

Open
fallintoplace wants to merge 2 commits into
apache:mainfrom
fallintoplace:fix/table-nonnegative-snapshot-ids
Open

fix(table): keep generated snapshot IDs non-negative#1619
fallintoplace wants to merge 2 commits into
apache:mainfrom
fallintoplace:fix/table-nonnegative-snapshot-ids

Conversation

@fallintoplace

Copy link
Copy Markdown
Contributor

What changed

Clear the sign bit before converting the UUID-derived snapshot ID to int64. The UUID folding logic is extracted into a small deterministic helper for regression coverage.

Why

Negating a negative value does not make math.MinInt64 positive because signed negation overflows back to the same value. Clearing the sign bit guarantees that generated snapshot IDs are nonnegative for every input.

Testing

  • Added deterministic coverage for an XOR result with only the sign bit set
  • Added coverage showing the remaining value bits are preserved
  • go test ./table

Signed-off-by: Minh Vu <vuhoangminh97@gmail.com>
@fallintoplace
fallintoplace requested a review from zeroshade as a code owner July 30, 2026 19:50
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