Skip to content

CBG-5792: Wait for the changes feed before starting a replicator - #517

Open
torcolvin wants to merge 3 commits into
mainfrom
fix/pull-resurrected-doc-changes-gate
Open

CBG-5792: Wait for the changes feed before starting a replicator#517
torcolvin wants to merge 3 commits into
mainfrom
fix/pull-resurrected-doc-changes-gate

Conversation

@torcolvin

Copy link
Copy Markdown
Collaborator

CBG-5792: Wait for the changes feed before starting a replicator

Fix test_pull_resurrected_doc flakes:

test_pull_resurrected_doc failed because an on demand import does not prime the caching feed before a one shot replication

  • Add an opt-in wait_for_caching_feed to the Sync Gateway write and read helpers, factored out of the readback update_document already did.
  • Update call sites that require wait_for_caching_feed that do not rely on import, which will be fixed separately.

test_pull_resurrected_doc failed because an on demand import does not prime the caching feed before a one shot replication

- Add an opt-in `wait_for_caching_feed` to the Sync Gateway write and read
helpers, factored out of the readback update_document already did.
- Update call sites that require wait_for_caching_feed that do not rely
  on import, which will be fixed separately.
@torcolvin

Copy link
Copy Markdown
Collaborator Author

@bbrks I'm interested in your feedback if there's a way we can fold this into a framework in a better way.

I propose committing this temporarily to hide this flake but then come up with better strategies for avoiding the flakes in the first place.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes are additive/opt-in and consistently applied at relevant call sites, with only minor doc/test-step wording nits noted.

Pull request overview

This PR hardens replication tests against Sync Gateway channel-cache timing by optionally waiting for written/imported revisions to appear in a request_plus _changes feed before starting a replicator, reducing flakes like test_pull_resurrected_doc.

Changes:

  • Added wait_for_caching_feed opt-in behavior to Sync Gateway helpers (update_documents, delete_document, get_document) and factored the “read-back from changes feed” logic into a shared helper.
  • Added SyncGatewayCluster.wait_for_sequence(...) to ensure all SGW nodes’ channel caches have caught up to a known sequence.
  • Updated several QE/dev_e2e tests to use wait_for_caching_feed=True at write/read points where immediate replication previously raced the cache/import pipeline.
File summaries
File Description
tests/QE/test_replication_upgrade_delta_sync.py Uses wait_for_caching_feed=True after SGW mutation to avoid cache-race before subsequent replication/validation.
tests/QE/test_replication_functional.py Waits for the caching feed after initial document creation to prevent role/channel replication races.
tests/dev_e2e/test_replication_filter.py Waits for the caching feed after creating a public-channel doc so the pull replicator sees it deterministically.
tests/dev_e2e/test_replication_behavior.py Reworks flake-prone steps to wait for cache/import visibility (including cluster-wide sequence catch-up) before replication.
tests/dev_e2e/test_replication_auto_purge.py Waits for caching feed after document creation to avoid timing-dependent replication behavior.
client/src/cbltest/api/syncgatewaycluster.py Adds a cluster-level helper to wait for a specific sequence across all SGW nodes.
client/src/cbltest/api/syncgateway.py Adds since support to get_changes, introduces _wait_for_caching_feed, and extends write/read helpers with wait_for_caching_feed.
Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread client/src/cbltest/api/syncgatewaycluster.py
Comment thread tests/dev_e2e/test_replication_behavior.py Outdated
torcolvin and others added 2 commits September 1, 2026 16:57
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants