How does stale query work?


Sorry, I know the documentation is very clear about how stale=ok should work. But, I am not seeing the right behavior.

I am running a _count reduce query with stale set to OK.

Query query = new Query();

I add a new document that changes the _count. I wait for about 10 seconds and then run the above query. I expect that automatic index to have run by now and should retrieve the latest count. But, I get back the old count. If the run the query again, I get the latest updated count. So, the system is behaving more like Stale.UPDATE_AFTER.

I have checked the auto index setting by running:

curl http://admin:password@localhost:8091/settings/viewUpdateDaemon

I get back:


Am I misunderstanding the way stale queries work? Thank you.

can you make sure you are running on full cluster or production mode?

5000ms is not enough, Couchbase also checks 5000 changes("updateMinChanges":5000) to re-index.

2 Answers

« Back to question.

What is your version of Couchbase Server? Java Client?

Is it possible to provide us with some sample output screenshots on what you are seeing?


« Back to question.

If **stale=ok** is set, Couchbase will not refresh the view even if it is stale. The benefit of this is a an improved query latency. If **stale=update_after** is set, Couchbase will update the view **after** the stale result is returned. If **stale=false** is set, Couchbase will refresh the view and return you most updated results.

Hope this helps!

You are just repeating what's in the documentation, which I understand. But, I am seeing a different behavior. That is why I posted my question.