You might have “tombstones” either be patient or adjust your bucket settings
Expiry Pager : Scans for items that have expired, and erases them from memory and disk; after which, a tombstone remains for a default period of 3 days. The expiry pager runs every 60 minutes by default: for information on changing the interval, see cbepctlset flush_param. For more information on item-deletion and tombstones, see Expiration.
You can tune this way down in the Buckets/Edit/Advanced Bucket Settings
The check “ Override the default auto-compaction settings?” Then adjust “ Metadata Purge Interval”
Yes delete with USE KEYS and bucket.remove() will do the same underlying request to the Key-Value server.
Can I assume that your queries were using N1QL (as opposed to the Key-Value API e.g. bucket.get(), lookupIn() or exists())? If so, they will have been hitting an index, and my guess is that this index had not yet been told by the Key-Value server about the removed documents. This eventual consistency is a great thing, as it means that you can decide at read time what level of consistency you require - e.g. you can request that the N1QL read is consistent with any mutations at the time of the query. Please take a look at the scan consistency docs for details: https://docs.couchbase.com/java-sdk/2.7/scan-consistency-examples.html
You might doing covered query. Unless Expiry Pager ran and removed documents REQUEST_PLUS will not help, Mutation is not recorded and indexer will not be updated.
Once expiration passed without Expiry Pager if directly retrieved document via SDK or N1QL the document marked as deleted.
If use non-covered query you will not get expired documents.
How do I know what my Expiry Pager settings are? Is there a way to retrieve that information easily? My subsequent query has an index on it. BTW I am no longer “expiring” the document. I am deleting it, as per the suggestions above. Does the same system apply? i.e. Do I need to wait until expiry pager runs? I thought I don’t need to if I am setting REQUEST_PLUS and doing delete.
Yeah, I tried this in the beginning, and just tried again. It is MOSTLY deleting the documents, however some documents still remain in the subsequent query. Would eventing give me guarenteed results if I went that route? Because this .remove method is not working with full accuracy it seems.
Couchbase Indexes are Eventual consistency,
As you are doing async call you should wait to finish the async call and issue N1QL query with REQUEST_PLUS to get the next list of documents. Also not sure how you are getting next list of documents. Are you using ORDER BY/LIMIT/OFFSET?
If you are using multiple threads then you need to synchronize those.