N1QL does not return some of the documents

Hello everyone!
Recently I’ve stumbled on an interesting issue with indexing in Couchbase. I’m running an integration test which adds 5 documents to Couchbase and triggers some service which retrieves them by using N1QL queries. Most of the time the test passes, but fails after a couple dozens of test runs because it can’t find some of the documents.
I’ve examined the database after the test failure. It turns out that sometimes, some documents do not get indexed, even after a very long time, like 30 minutes (I’m able to retrieve documents by ID but not by SELECT * FROM bucket).

I’m using couchbase community docker container with default query consistency, version=4.0.0-4051 with the Java SDK, I’m not mutating any keys.

We start couchbase docker container before all the tests, then before each test we flush the bucket. Can that cause any problems? Are we guaranteed that all documents will be eventually indexed (what is the max time for 5 documents)?

Queries in Couchbase data provide consistency flags. If you’d like your test to pass reliably, pls use scan_consistency=request_plus (SDK should provide a simple flag for the query verb). In the case of request_plus, you will get an error (timeout) if the index isn’t caught up to the time-stamp of the query.

Not indexing after 30 mins is not something we have seen here. I suspect there is something seriously about the indexer. could you send the indexer.log file, if you still experience the issue after the scan_consistency setting is set to request_plus?
thanks
-cihan

In my tests instead of relying on scan_consistency=request_plus I just use retrying with timeout - it shouldn’t influence the result in the end if the timeout is long enough, right? Anyway I can’t flush + rely on request_plus setup because of https://issues.couchbase.com/browse/MB-16957

After a long time I’ve managed to reproduce the issue by running in a loop

  1. flushing of bucket
  2. adding 5 documents
  3. retrying for 1 minute to find all 5 documents.
    I ended up with 3 documents indexed, though there are 5 documents in CB. Tried to query documents with cbq after around 20 minutes, still documents cannot be found with a query (select * from bucket_name) but couchbase UI shows all the documents.

Here’s the indexer.log https://drive.google.com/file/d/0ByhFXUmEZFe7N2xHcm9KX1dOLXM/view?usp=sharing

Thanks,
Radek

thanks - yes I know about the issue on flush. instead of flush, could I ask you to try DELETE FROM bucket with N1QL? without scan_consistency set to request_plus we cannot guarantee that data will be there in the index.