Skip to content

[4.1.2 Backport] CBG-5522: Implement ScanResultIterator.Err() in gocb range scan wrapper - #8548

Open
bbrks wants to merge 1 commit into
CBG-5460-4.1.2from
CBG-5522-4.1.2
Open

[4.1.2 Backport] CBG-5522: Implement ScanResultIterator.Err() in gocb range scan wrapper#8548
bbrks wants to merge 1 commit into
CBG-5460-4.1.2from
CBG-5522-4.1.2

Conversation

@bbrks

@bbrks bbrks commented Aug 5, 2026

Copy link
Copy Markdown
Member

CBG-5522

Clean cherry pick of #8403 to 4.1.2

Second of a 6-PR stack backporting CBG-5547, stacked on the CBG-5460 backport. This PR is a prerequisite discovered while cherry-picking: the sg-bucket version the CBG-5547 layers need adds Err() to the ScanResultIterator interface, and this is the commit that implements it in the gocb range scan wrapper. Without it the tree does not compile.

Dependency upgrade — what is actually changing

github.com/couchbase/sg-bucket d9dd0c058146fc995d3ac4be (compare):

Commit Change Risk
#148 CBG-5522: Add Err() to ScanResultIterator interface for range scans Interface addition. Breaks the build until the implementations catch up, which is what this PR's Go changes do

github.com/couchbaselabs/rosmar 3e0b3eaeb1b111d9680fd14d (compare):

Commit Change Risk
#82 CBG-5522: Implement ScanResultIterator.Err() Matches sg-bucket #148
#69 CBG-4232 implement hierarchical subdoc path support The one functional rosmar change in this stack. Affects rosmar's subdoc handling, so it changes unit-test behaviour under the rosmar backing store; it cannot affect a Couchbase Server deployment

Verified on CE with the rosmar backing store: go build ./..., go vet ./..., go test ./base/, golangci-lint run --config=.golangci-strict.yml --new-from-rev=origin/release/4.1.2 and golangci-lint fmt --config=.golangci-strict.yml --diff. The range scan tests only exercise the gocb wrapper against a real Couchbase Server, and integration tests were not run — so the Err() implementation itself is covered by compile and lint here, not by an executed test.

No [4.1.2 Backport] ticket exists for this change, so the title carries the upstream ticket key.

🤖 Opened with the sync-gateway-backport skill in Claude Code

… range scan wrapper

Cherry-picked from 769dfca (CBG-5522, #8403).

Co-authored-by: Ben Brooks <ben.brooks@couchbase.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@bbrks
bbrks marked this pull request as ready for review August 6, 2026 14:47
@bbrks
bbrks requested review from a team and a lite review from Copilot August 6, 2026 14:47

Copilot AI 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.

Pull request overview

Backports CBG-5522 to the 4.1.2 branch by updating sg-bucket/rosmar dependencies and implementing the newly-required ScanResultIterator.Err() method for the gocb range scan wrapper so the tree compiles and range scan behavior can be inspected consistently.

Changes:

  • Bump github.com/couchbase/sg-bucket and github.com/couchbaselabs/rosmar to versions that add/implement ScanResultIterator.Err().
  • Implement Err() for gocbScanResultIterator and adjust Close() behavior to preserve/translate stream errors consistently.
  • Extend range scan tests to assert Err() behavior, including post-Close() cancellation semantics.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
go.mod Updates sg-bucket and rosmar module versions required by the new iterator interface.
go.sum Updates checksums for the upgraded sg-bucket and rosmar versions.
base/collection_rangescan.go Adds gocbScanResultIterator.Err() and refines Close() error/cancellation handling.
base/collection_rangescan_test.go Adds Err() assertions and a subtest validating cancellation visibility after Close().

Comment on lines +121 to +134
t.Run("CloseCancellation", func(t *testing.T) {
iter, err := scanStore.Scan(ctx, sgbucket.NewRangeScanForPrefix("doc_"), sgbucket.ScanOptions{IDsOnly: true})
require.NoError(t, err)
for item := iter.Next(ctx); item != nil; item = iter.Next(ctx) {
require.NotEmpty(t, item.ID)
}
// Clean end-of-stream: no error is reported until Close is called.
require.NoError(t, iter.Err())
// A clean Close returns nil...
require.NoError(t, iter.Close(ctx))
// ...but records a cancellation, surfaced by a later Err (gocb parity),
// identically on the Rosmar and gocb-backed implementations.
require.ErrorIs(t, iter.Err(), sgbucket.ErrScanCancelled)
})
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