AtPlus scan consistency option with multiple index node replicas

Given: Index below (please note we use 2 replicas)
CREATE INDEX index_catalogitem_quota_duration ON accountMgmt(accountToken,durationMinutes) WHERE ((type = “catalogItem”) and (status = “RECORDED”)) WITH { “num_replica”:2 }

Two services using above index. First service inserts a new document and then executes N1ql select query using index above and N1qlParams.consistentWith parameter with inserted previously document (aka AtPlus option).

Based on the documentation, my assumption is that the query will just wait for the documents that you specify to be indexed before running the query (including indexing on ALL replicas)

After execution the query by the first service (using index_catalogitem_quota_duration index) the first service sends notification to the second service which execute the same query using the same index (index_catalogitem_quota_duration) and sometimes (pretty rare ) it’s missing the document inserted by the first service.

Now my question is would be the document indexed on all index nodes (active and two replicas) or just on active node before query will be executed?

Thank you

If I understand your question correctly, you’ll want to pass the AT_PLUS parameter to all queries. Just because the first service executed with it does not guarantee subsequent queries will be serviced by the same index replica.

Is there any way to force indexing on active and all index replicas before query will be executed by the second service

The two mechanisms we have in the query service at the moment are REQUEST_PLUS and AT_PLUS.

Are you issuing the second query with AT_PLUS as well? Is it from the same application instance that did the updates, or possibly another one in a similar loadbalancer group? If the latter, then AT_PLUS wouldn’t know about the specific mutations, so REQUEST_PLUS would be the way to issue the query.

Second query is issued from another service and as you had explained before could hit another index node. To fix it we consider two options:

  1. passing mutation token info along with the notification to the second service, so second service will use it to issue query with AT_PLUS as well.
  2. using REQUEST_PLUS to issue request to DB from the first service. But this approach could hit service performance because in every moment multiple documents indexed with the same index and as result the query should wait for the index to catch up to the request timestamp. Is my understanding correct that delay will depend on updating index with all documents added/changed before the current document’s update was issued?

Hi @vlad_a, Yes your understanding is correct. When using REQUEST_PLUS, the latency depends on time it takes to index all documents before request_plus timestamp.