I’m trying to upgrade the SDK from beta1 to beta3 in our .NET application, the build is successful, but the APIs do not work as before. All seems fine until I try to retrieve a document and then I get an exception. The code flows as follows…
var options = new ClusterOptions()
.WithServers(clusterOptionsServers)
.WithCredentials(username, password)
.WithBucket(_configBucketName);
_cluster = new Cluster(connectionString, options);
var bucketResult = _cluster.BucketAsync("Known_BucketName");
bucketResult.Wait();
var collection = bucketResult.Result.DefaultCollection();
documentResult = collection.GetAsync("Known_Doc_Key");
Innermost exception trace is showing:
{System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
at Couchbase.Core.ClusterNode.ExecuteOp(IConnection connection, IOperation op, CancellationToken token, Nullable1 timeout) at Couchbase.CouchbaseBucket.SendAsync(IOperation op, CancellationToken token, Nullable1 timeout)
at Couchbase.Core.Retry.RetryOrchestrator.RetryAsync(BucketBase bucket, IOperation operation, CancellationToken token, Nullable1 timeout) at Couchbase.Core.Retry.RetryOrchestrator.RetryAsync(BucketBase bucket, IOperation operation, CancellationToken token, Nullable1 timeout)
at Couchbase.KeyValue.CouchbaseCollection.ExecuteLookupIn(String id, IEnumerable`1 specs, LookupInOptions options)
at Couchbase.KeyValue.CouchbaseCollection.GetAsync(String id, GetOptions options)}
Any ideas what could be wrong or what needs to be changed (from beta1 usage shown above) in order to retrieve a document from a bucket? Are there any examples or sample code available for using the beta3 API? The ‘Couchbase.SDK3.0.Examples’ out on github no longer compile with beta3.
I cut and pasted your code, replacing clusterServerOptions with my server IP and connectionString and ran it against 6.5 beta (build 4.6.1) and was able to successfully do the read:
Thanks for trying. I’m don’t know what is different. I tried a couple different buckets with different known doc keys and always get the exception. I notice that when I hover over the bucketResult.Result in the debugger it has a “SupportsCollections” member which is showing as false. Is that anything meaningful? Also, the GetAsync call itself does not throw, but when I call documentResult.Wait() afterwards (as I was doing to allow the operation to complete) or if I immediately call documentResult.Result.ContentAs() (as you are doing) it will throw in either case.
No, I don’t think so; collections are a developer preview opt-in and if they are not enabled, the SDK will use a fake default collection. Unless of course there was a bug there
This could be the case, can you upload an exact example?
In this case, the exception occurs on the collection.GetAsync call to retrieve a document:
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
at Couchbase.Core.ClusterNode.ExecuteOp(IConnection connection, IOperation op, CancellationToken token, Nullable`1 timeout)
at Couchbase.CouchbaseBucket.SendAsync(IOperation op, CancellationToken token, Nullable`1 timeout)
at Couchbase.Core.Retry.RetryOrchestrator.RetryAsync(BucketBase bucket, IOperation operation, CancellationToken token, Nullable`1 timeout)
at Couchbase.Core.Retry.RetryOrchestrator.RetryAsync(BucketBase bucket, IOperation operation, CancellationToken token, Nullable`1 timeout)
at Couchbase.KeyValue.CouchbaseCollection.ExecuteLookupIn(String id, IEnumerable`1 specs, LookupInOptions options)
at Couchbase.KeyValue.CouchbaseCollection.GetAsync(String id, GetOptions options)
Unfortunately, I still cannot reproduce using the code above and 6.5-beta (build 4261) - I ran it several times and it was successful every time.
If there are any other details you can provide that may be helpful. You may want to try upgrading your server from build 4038 to 6.5-beta3. You can create a bug ticket in Jira and monitor it there if you would like. Additionally, you may want to pull the source for tag 3.0.0-beta3 in github and see if you can set a break point and determine exactly what argument is invalid.
I’ll give it a shot too, but fwiw @atkinsr, I’ve been working with beta.3 as well and haven’t seen this kind of basic failure. I’m using .NET Core 3.0.100 on MacOS, loading dependencies via nuget (from within VS Code).
I’m not an expert here, but I’m wondering if some artifact is resolving to the wrong thing for some reason in your env.
I built with the src code for 3.0.0-beta3 to try to get more detail on the error. I am now seeing this internal error at GetAsync():ExecuteLookupIn(): {KV Error: {Name="UNKNOWN_COLLECTION", Description="Operation specified an unknown collection.", Attributes="invalid-input"}}
But I’m not so sure this isn’t a red herring as the only collection is the default collection. I tried all these combinations to get the collection:
var collection = bucketResult.DefaultCollection();
var collection = bucketResult.Collection(“_default”);
var collection = bucketResult.DefaultScope().Collection(“_default”);
All seem to return a valid collection, named “_default”, but the subsequent GetAsync call fails identically. @ingenthr – I have a nearly identical setup except that I’m running on Windows. I’ll keep trying to isolate issue. Thanks for the comment/suggestion.
Just to close out this topic. The issues that I noted above were resolved with beta4. That is to say, after updating to SDK 3.0.0-beta4, I did not experience any of these issues.
Thanks,
-Ryan