Fix wait_for_caching_feed && add to create_document and delete_document - #510
Open
torcolvin wants to merge 2 commits into
Open
Fix wait_for_caching_feed && add to create_document and delete_document#510torcolvin wants to merge 2 commits into
torcolvin wants to merge 2 commits into
Conversation
The changes feed read was passing both `doc_ids` and `request_plus`, which are mutually exclusive in effect. Sync Gateway consumes `RequestPlusSeq` only in `SimpleMultiChangesFeed`; supplying `doc_ids` routes the request to `DocIDChangesFeed`, which calls `GetDocument` per id straight out of the bucket and never consults the channel cache. `request_plus` was therefore ignored and the call returned as soon as the document was readable, which is before the caching feed has it. Measured on a 3-node cluster: the call returned in ~9ms with the document absent from the unfiltered feed. Reading the unfiltered feed instead, it blocks until the revision is actually cached (~1.5s in two of five samples) and the document is in the feed on every return. The parameter still populates `seq` and still detects a concurrent write the same way; only the wait it advertised was missing. The error message no longer dumps the whole feed, now that the feed is not filtered to one document. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
- The first attempt at wait_for_caching_feed didn't work as I thought. request_plus does not apply to either continuous or doc_id filtered feeds. To work around this, I created post-filtering of changes feeds for docids. - Add argument to create_document/delete_document - Add option for RemoteDocument to be a tombstone - Start reading changes feed at 0, but retry on the last since value. If this was called from a single client, the request_plus should take care of it, but if we use this wait technique elsewhere, this needs to retry changes feed logic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix wait_for_caching_feed && add to create_document and delete_document
request_plusdoes not apply to either continuous or doc_id filtered feeds. To work around this, I created post-filtering of changes feeds for docids after getting the entire set of documents over changes feed. This is not efficient but there are not that many circumstances where this is used. In the future, I can add a wait function to wait for doc_ids + revids.create_document/delete_documentforwait_for_caching_feedRemoteDocumentto be a tombstone to makedelete_documentAPI more clearThe changes in #495 do not need this for upserted or removed documents, but there are race conditions around upserting those documents and doing a one shot replication for Couchbase Lite, so I'm making this code stronger in the helpers.