Skip to content

Fix/changestream early start lazy oplog - #727

Merged
eerxuan merged 6 commits into
documentdb:mainfrom
samafarc:fix/changestream-early-start-lazy-oplog
Nov 6, 2026
Merged

eerxuan merged 6 commits into
documentdb:mainfrom
samafarc:fix/changestream-early-start-lazy-oplog

Conversation

@samafarc

@samafarc samafarc commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

test_changeStream_early_start.py called _oldest_oplog_ts(collection) for every case before running the command. Only oldest_minus_5s uses the value. zero, one_zero and max_increment ignore it. On an engine with no readable local.oplog.rs, those cases failed with StopIteration before the command ran, which hid whether the engine accepts an early startAtOperationTime.

Changes:

  • compute_start now takes a callable, so only oldest_minus_5s reads the oplog.
  • The amazon-documentdb profile no longer declares oplog: on Amazon DocumentDB, local lists no collections and a find on local.oplog.rs returns no document.
  • oldest_minus_5s requires oplog. The requires gate reads only the closest requires marker, and a function-level marker is closer than a case marker, so the change_streams requirement moves to module level and the oldest_minus_5s case marker restates it alongside oplog.
  • The two collMod cases that target local.oplog.rs (max_target_oplog, size_target_oplog) now require replication instead of oplog. They only check that collMod rejects cappedMax/cappedSize on the oplog.rs namespace with InvalidOptions, which Amazon DocumentDB does, so they keep running there. A standalone still skips them.
  • The replication capability description now names only applyOps, so it no longer overlaps with oplog.

Testing (early_start + collMod capped_max + capped_size):

  • MongoDB 8.2.4 replica set, --engine-name mongodb: 80 passed on main and branch; oldest_minus_5s x3 and both collMod oplog cases run and pass.
  • MongoDB 8.2.4 standalone, --engine-name mongodb: 66 passed; the early-start cases and both collMod oplog cases are deselected.
  • MongoDB 8.2.4 replica set, --engine-name amazon-documentdb (*_target_view excluded: mongod segfaults on it and its xcrash mark is scoped to engine=mongodb): main 80 passed, branch 77 passed with oldest_minus_5s x3 deselected.
  • Amazon DocumentDB 8.0 (local engine), --engine-name amazon-documentdb: on main oldest_minus_5s fails with StopIteration in all 3 scopes and both collMod oplog cases pass; on the branch oldest_minus_5s is deselected and both collMod oplog cases still pass.
  • pytest -m unit: 152 passed. pre-commit (black, isort, flake8, mypy) clean.

@samafarc
samafarc requested a review from a team as a code owner October 19, 2026 20:18

@eerxuan eerxuan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Summary

Reading the oldest oplog entry only in the one case that uses it is a clean fix: the three static cases no longer depend on a readable local.oplog.rs, and oldest_minus_5s is gated with the same per-case requires(oplog=True) the collMod oplog.rs cases use. Each test still makes one assertion. Only minor points below.

Suggestions

  1. [Suggestion] preconditions.py: the profile changed in the second commit drops oplog but keeps replication, and replication is described as "replication commands are available (applyOps, oplog access)". Please reword that description to cover only applyOps, so the two capabilities don't overlap. Otherwise the profile looks like it claims oplog access through replication.

Questions

  1. [Question] The description says the profile change wasn't run against a live server. It now skips three cases on that profile (oldest_minus_5s and the two collMod oplog.rs cases). Can you confirm, from one run against that target, that local.oplog.rs isn't readable there, so the skips don't drop coverage that used to pass?
  2. [Nitpick] The branch is 3 commits behind main. Please rebase before merge.

Positive Feedback

  • The compute_start docstring now says why the oplog is read lazily, so the next case author knows not to call it for a static start time.

@documentdb-triage-tool documentdb-triage-tool Bot added bug Something isn't working compatibility test Compatibility test related labels Nov 5, 2026
@documentdb-triage-tool

Copy link
Copy Markdown

🤖 Auto-triaged by documentdb-triage-tool.

Applied: compatibility test, bug
Project fields suggested: Component test-coverage · Priority P2 · Effort M · Status Needs Review
Confidence: 0.82 (mixed)

Reasoning

component from path globs (test-coverage, test-framework); effort from diff stats (17+13 LOC, 2 files); LLM: Fixes a premature oplog read in changestream tests that causes false failures on engines without local.oplog.rs, masking valid early-startAtOperationTime behavior; touches test files and profile config across one component.

If a label is wrong, remove it manually and ping @patty-chow so the rules can be tuned. The bot will not re-label items that already have component labels.

test_changeStream_early_start looked up the oldest oplog entry for
every parametrized case, before running the change-stream command.
Only oldest_minus_5s uses that value; zero, one_zero and max_increment
use static start times. On a target with no readable oplog entry the
lookup raises StopIteration, so those three cases never reach the
server and record nothing about whether an early startAtOperationTime
is accepted.

Pass compute_start a callable that performs the lookup, so the oplog
is read only by the case that uses it.

Signed-off-by: Samar Farooqi <samafarc@amazon.com>
Amazon DocumentDB does not expose its replication log as
local.oplog.rs: reading the oldest entry returns no document. The
amazon-documentdb profile declared the oplog capability anyway, so
oplog-dependent cases ran and failed in test code rather than being
gated.

Remove oplog from the profile and mark the oldest_minus_5s case of
test_changeStream_early_start with requires(oplog=True), the one case
that reads the oplog. The two collMod oplog cases
(max_target_oplog, size_target_oplog) are already gated on oplog and
are now skipped on Amazon DocumentDB.

Signed-off-by: Samar Farooqi <samafarc@amazon.com>
…pplyOps

Oplog access is covered by the separate oplog capability, so the
replication description should name only applyOps to keep the two
capabilities from overlapping.

Signed-off-by: Samar Farooqi <samafarc@amazon.com>
… marker

The requires gate reads only the closest requires marker, and the
function-level change_streams marker sits closer than a case's own
marker, so the oplog requirement on oldest_minus_5s was ignored and the
case still ran on targets without a readable oplog. Move the
change_streams requirement to module level and restate it on the
oldest_minus_5s case alongside oplog, so the case marker is the closest
one and carries both requirements.

Signed-off-by: Samar Farooqi <samafarc@amazon.com>
max_target_oplog and size_target_oplog only check that collMod rejects
cappedMax/cappedSize on local.oplog.rs with InvalidOptions. They need the
oplog.rs namespace to exist, not a readable oplog, so gating them on oplog
skipped them on Amazon DocumentDB, which returns InvalidOptions for both.

Gate them on replication instead. They still run on a MongoDB replica set
and are still skipped on a standalone, which has no oplog.rs.

Signed-off-by: Samar Farooqi <samafarc@amazon.com>
@samafarc
samafarc force-pushed the fix/changestream-early-start-lazy-oplog branch from 2a39565 to 9087c2f Compare November 6, 2026 00:40
@samafarc

samafarc commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @eerxuan, all three are addressed:

  1. replication description: it now says "replication commands are available (applyOps)", so oplog access lives only under the oplog capability.
  2. Is local.oplog.rs readable on that target: checked on a live Amazon DocumentDB 8.0 engine. local lists no collections and a find on local.oplog.rs returns no document, so oldest_minus_5s can't run there (on main it fails with StopIteration in all 3 scopes before reaching the server). You were right about the collMod cases, though: max_target_oplog and size_target_oplog pass on DocumentDB today, since they only check that collMod rejects options on oplog.rs. I re-gated them on replication, so they keep running on DocumentDB and a MongoDB replica set and are still skipped on a standalone. While checking this I also found oldest_minus_5s wasn't actually deselected, because the requires gate reads only the closest marker; the case marker now restates change_streams alongside oplog.
  3. Rebase: rebased onto current main (10eec47).

@eerxuan
eerxuan merged commit 0aa08b6 into documentdb:main Nov 6, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working compatibility test Compatibility test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants