Could not acquire server - exception

#1

On an InsertAsync what does a reply with an Exception = {“Could not acquire a server.”} mean?

How can this be fixed?

Could not acquire server
#2

@ibrahim.hadad -

It means the SDK cannot acquire a server object to execute an operation. In normal operating conditions this is a very uncommon error. Typically, you would see these during failover/rebalance scenario under heavy workload.

Can you describe the situation that led up to the error? What version of the SDK and CB server are you using? If you can reproduce it, can you post the logs?

-Jeff

#3

@jmorris thanks for replying.

Sorry no logs! We are running this under a test rig.

We are using CB 4.1. Single node cluster running on localhost.
SDK .NET 2.2
The code can be found here:

See line 95. That’s were we are getting the reply with the message I sent to you earlier in the result var “dr”.

Any help would be appreciated since we are stuck.

#4

@jmorris One more comment.

To see where the bucket and cluster are configured you can see where it begins (line 49) here:

which leads to:

See the method:
CreateCouchBaseDBClientConfiguration

That’s where the CouchBase configuration is built. Then it returns back to CouchBaseDBExtension.cs to open the bucket. Which is used in the CouchBaseDBJournal.WriteMessagesTask(see line 95).

I hope this further clarification helps.

Could not acquire server exception, can't connect to server all the time
#5

@ibrahim.hadad -

I think the problem may be related to the fact you are not maintaining a reference to the cluster object and perhaps it is going out of scope. The Cluster and Bucket objects should be long-lived objects, created when the application is created and disposed when the application shuts down. The using statement on line 52 means the cluster and it’s buckets will be disposed and cleaned up as soon as the thread leaves that scope.

Typically, you would make the Cluster and Bucket instances static or use a singleton. Luckily, there is an object which handles this for you: ClusterHelper. Read this: http://developer.couchbase.com/documentation/server/4.1/sdks/dotnet-2.2/cluster-helper.html

-Jeff

1 Like
#6

@jmorris Thanks a bunch! Let me look into this. Makes sense.

I’ll report back here with what I did to fix it so that others can benefit later.

Regards,

Abe

#7

We took the using statement out and it solved out problem :grinning:. Thanks!

1 Like