[4.1.2 Backport] CBG-5522: Implement ScanResultIterator.Err() in gocb range scan wrapper - #8548
Open
bbrks wants to merge 1 commit into
Open
[4.1.2 Backport] CBG-5522: Implement ScanResultIterator.Err() in gocb range scan wrapper#8548bbrks wants to merge 1 commit into
bbrks wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
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-bucketandgithub.com/couchbaselabs/rosmarto versions that add/implementScanResultIterator.Err(). - Implement
Err()forgocbScanResultIteratorand adjustClose()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) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 theScanResultIteratorinterface, 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-bucketd9dd0c058146→fc995d3ac4be(compare):Err()toScanResultIteratorinterface for range scansgithub.com/couchbaselabs/rosmar3e0b3eaeb1b1→11d9680fd14d(compare):ScanResultIterator.Err()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.2andgolangci-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 theErr()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-backportskill in Claude Code