Help! Couchbase returns different data

Hello Team!

I have a couchbase server on an AWS EC2 instance, and I have a Golang app connected to it deployed on Elastic Beanstalk. My queries ran successfully (from the sdk), and returns the right data when called (from the golang api). I manually ran a Delete query from couchbase web admin, and I populated data again (from a seed method in the Go app). When I try the endpoints again it returns null

NB: I have a local server (same Go app), and I tried the endpoint again, this time connecting my Local Go app to the remote database, and the query works, it returns the data as expected.

Why isn’t it returning from the live app?

PS: Both local and live Go apps are on same version:
Both run the same set of queries:
SELECT * FROM bucketname AS contents WHERE type = 'content'

I had restarted both the couchbase server, and my app’s server and waited over an hour, still no changes, what could be the cause of this?

Queries uses index and indexes are built asynchronously, So index will little behind. You can
set scan_consistency

Thanks, do I set scan_consistency on my code, or on the database server?

In code. it is per each request

1 Like

@vsr1 I made the change, it didn’t work. Data returned is still null. Here’s the code I’m using to fetch data from couchbase:

query := gocb.NewN1qlQuery("SELECT * FROM bucketname AS contents WHERE type = 'content' ")
	query.Consistency(gocb.RequestPlus)
	rows, err := Bucket.ExecuteN1qlQuery(query, nil)

Try in web console
SELECT * FROM bucketname AS contents WHERE type = ‘content’;
SELECT META().ID FROM bucketname AS contents WHERE type = ‘content’;

If that doesn’t work post EXPLAIN output

@vsr1 I ran both from workbench, they both returned data. However, I tried the endpoint which pulls data with same query, it still returns null

I am not expert in gocb. cc @ingenthr

Sorry for the trouble @codehakase.

The most common problem we see in golang is not checking err. If you’re definitely doing that, then I might recommend setting up the verbose logger if possible and perhaps we can spot something.

One suspicion I have is perhaps there’s something about bootstrap with the beanstalk env. I don’t know that for sure-- I’m hoping the logging will give us more info.

Also, note that we tried this in our environment and don’t see the same behavior. Let us know what you come up with @codehakase.

Thanks @ingenthr I was able to figure out the cause, your suspicion was valid, Elastic Beanstalk wasn’t updating the container I had made the changes to the code to. I had to manually upload the config and updated the version number.

Thanks once again

Glad you figured it out! If you have another moment, I’d be curious… was the logging helpful to this end, or did you have to dive in further with other diagnosis?

The answer might help the next person who lands on this thread from a search. :wave:

I wasn’t able to use the log package (go get couldn’t find it), What I did was update my queries to set consistency - query.Consistency(gocb.RequestPlus) and redeployed to Elastic Beanstalk