Bucket Creation via REST API - operation result

Hello,
A question in regards of general Bucket creation flow when using REST API.
We are observing following scenario:

Setup:
We are using Couchbase .NET SDK 3.4.14, against Couchbase Community 7.2.2 version.
Now, for Bucket creation operation, we are (were originally) using POST method via uri: “http://[cb_url]/pools/default/buckets” according to REST API docs. Upon getting successful result (2xx) we continue by inserting data into respective bucket(s).

Problem:
We noticed intermittently during this process that when trying to insert data, we get an error (exception) indicating that (ephemeral in concrete case) bucket does not exist. Again, data insertion is started only after we pass async POST call with SUCCESS response from SDK side.
Now, we also empirically noticed this issue less frequent after increasing DefaultSendQueueCapacity on CB during the cluster initialization.

Current workaround/solution:
We found that adding following code after Bucket creation SUCCESS via POST, as described above:

//ClusterAdmin being instance of ICluster
var bucket = await ClusterAdmin.BucketAsync(bucketName);

Seems to resolve the issue.

Now, ICluster.BucketAsync internally calls Cluster.GetOrCreateBucketAsync, which creates Bucket if it does not exist, handles bootstraping the bucket, etc… and in this concrete case makes initial POST request actually redundant.

Finally a question:
Can you please confirm on the flow/following - success result of above mentioned POST operation when creating Bucket, is actually indicating only that Bucket creation was triggered on server side (entered SendQueue), not that Bucket itself was sucessfully created.

Note that Cluster.GetOrCreateBucketAsync doesn’t create the bucket on the server…it either returns a cached IBucket reference or it creates a new one on the client only. The bucket must already exist on the server for it to succeed.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.