Delay in updating Index


We create a following document in couchbase
“customerAsset”: {
“CustomerId”: “28748347”,
“AccountID”: “247837438”,
“Product”: “27382748”
There are indexes both on customer id and account id attributes.
Once create of this document is finished and we answer back with an Id to consumer there is immediately a query call being made with either customer id or account id and that is resulting in document not found.
Difference between create and query call is in magnitude of 10-50 msec

We believe there is a certain amount of time being taken for index to be updated which is resulting in document not found. However if same query is done after 1 or 2 secs there is no issue.

For this purpose we are now planning to introduce a delay in create call before we answer consumer back. This is more a workaround and we are aware of the fact that indexes are updated asynchronously. Is there any way that we can reduce the delay there?

We are using Couchbase Community Edition 6.0

You can use REQUEST_PLUS/AT_PLUS consistency with the query. Indexer will wait for the indexes to catchup with latest mutations before answering the scan.

If scan latency with request plus is high, it would be good to check if Indexer is able to keep up with the data mutations using the stats REST API. If num_docs_pending/num_docs_queued is high, better sizing(increasing memory quota, CPU, disk IO etc depending on which part is saturated) would help.

1 Like