.NET SDK 3.0.0-beta3 changes (code from beta1 no longer working)

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.

@atkinsr -

What server version are you using?

-Jeff

We are running on: Couchbase Server Enterprise Edition 6.5.0 build 4380

I tried falling back to beta2, but then ran into this issue which doesn’t appear to have a workaround
https://issues.couchbase.com/browse/NCBC-2190

For beta3, GetDefaultCollection() was returning OK, but the first attempt to call GetAsync on it with a valid doc key is what is failing now.
-Ryan

@atkinsr -

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:


Are there any other settings I am missing to help recreate?

-Jeff

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 :slight_smile:

This could be the case, can you upload an exact example?

I’ve reproduced this again, now using simply the ‘Couchbase.SDK3._0.Examples’ project with Program.cs contents replaced with the following:


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)

@atkinsr -

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.

-Jeff

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.

@atkinsr -

That is odd; from your earlier post you don’t have collections enabled. I did find a bug that occurs when developer preview (and thus collections) is enabled in CB version 6.5: https://github.com/couchbase/couchbase-net-client/commit/f26726e6e01cb470877b6ba21762374e1bbe15fe

This caused a CollectionNotFoundException, not exactly what you have put up there, but worth a shot.

-Jeff

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

1 Like

Good to hear @atkinsr!