Skip to content

CBG-5411: match Couchbase Server Incr behavior for def > int64 max#76

Merged
bbrks merged 1 commit into
mainfrom
CBG-5411
May 27, 2026
Merged

CBG-5411: match Couchbase Server Incr behavior for def > int64 max#76
bbrks merged 1 commit into
mainfrom
CBG-5411

Conversation

@bbrks

@bbrks bbrks commented May 27, 2026

Copy link
Copy Markdown
Member

CBG-5411

When def exceeds math.MaxInt64, sync_gateway's gocb-backed Incr casts it to int64 (which goes negative), and gocbcore interprets that as the "do not create if absent" sentinel — the server then returns KEY_ENOENT. Rosmar previously created the doc with the wrapped value instead.

Detect the sentinel and return sgbucket.MissingError to match.

TestIncr is now table-driven and covers the matrix verified against both backends: amt=0 (read-but-rewrite + CAS bump), uint64-wrap "negative" amt, missing vs existing key, and the new def-sentinel case in both states. Adds a small ptr[T] helper in utils.go used by the test seed values.

When def exceeds math.MaxInt64, sync_gateway's gocb-backed Incr casts it
to int64 (which goes negative), and gocbcore interprets that as the
"do not create if absent" sentinel — the server then returns KEY_ENOENT.
Rosmar previously created the doc with the wrapped value instead.

Detect the sentinel and return sgbucket.MissingError to match.

TestIncr is now table-driven and covers the matrix verified against
both backends: amt=0 (read-but-rewrite + CAS bump), uint64-wrap
"negative" amt, missing vs existing key, and the new def-sentinel
case in both states. Adds a small ptr[T] helper in utils.go used by
the test seed values.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bbrks bbrks requested a review from gregns1 May 27, 2026 11:34

@gregns1 gregns1 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.

LGTM

@bbrks bbrks merged commit 42bfa64 into main May 27, 2026
15 checks passed
@bbrks bbrks deleted the CBG-5411 branch May 27, 2026 13:09
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.

2 participants