Couchbase Golang "failed to get query provider: not connected to cluster | {"statement":"*"}"


Go (also known as Golang) is an open source programming language developed by Google

Couchbase is a NoSQL database built for business-critical applications.

While using Golang sdk 2.0 for Couchbase, I encountered an error "failed to get query provider: not connected to cluster | {"statement":"*"}"

But this error had a strange behaviour, whenever I run any insert or update operation via Sdk function prior running Cluster.Query(query, &gocb.QueryOptions{NamedParameters: params}) this error didn't occurred. 

Running Just Cluster.Query(query, &gocb.QueryOptions{NamedParameters: params}) after connection directly would get "failed to get query provider: not connected to cluster | {"statement":"*"}"

What I did to tackle this is, prior to the Query function or immediately after running the connect function I ran a atomic function 
collection.Binary().Increment("serverUp", &gocb.IncrementOptions{
Initial: 1,
Delta: 1,
}) 

What I got from the above code is an counter for my server up and riddances from the error discussed above.

This article was published on 17th may 2020.

Couchbase might have fixed the issue while you watch this, but if you using previous version or still this error exists, you can get a workaround from the above implementation.

Comment below if need further explanation.

Comments

Popular posts from this blog

Add/Set collection in Firestore with the Firebase Admin SDK : Python 🐍

Writing to external SD card in Android 5.0 and above

Add/Set array in Firestore with the Firebase Admin SDK : Python 🐍