I am using the latest Go sdk - v2.3.3
Server version: 6.6.3
I am using the Queue pop method like this:
err := v.bucket.DefaultCollection().Queue(someKey).Pop(&someValue)
When this is being called in parallel (I tested it using goroutines) it returns an error “StatusKeyExists”.
I did some deep digging and I saw that there’s a place where the SDK convert the “cas mismatch” error to a “document exists” (collection_subdoc.go, line 336), and because of that the pop function doesn’t retry the operation and simply returns the “document exists” error
Is this a bug in the SDK? or am I missing something?
Hi @Eli_gotesman I’ll confirm tomorrow but looking at this I suspect that you’re correct and we’re not matching the error correctly. If this is the case then I’ll get it fixed and in the next gocb release.
Do you have an estimation for the release?
We have this issue on our production and it causes some errors to our users, is there any walk-around we can do until the fix will be released?
@Eli_gotesman we release the Go SDK on the third Tuesday of each month so the next release is scheduled for November 16. I think that the only workaround would be to wrap your call into Pop with a loop and detect the document exists error - basically moving the error handling logic the SDK already does a layer up, e.g.
err := myQueue.Pop(&myval)
if err != nil {
if errors.Is(err, gocb.ErrDocumentExists) {
// recurse or loop
}
// handle the error
}
return myval