Skip to content

fix: skip PathNotViable in the full-sync oplog window - #1072

Open
FranzLi347 wants to merge 1 commit into
alibaba:developfrom
FranzLi347:fix/bulk-update-overlap-window
Open

FranzLi347 wants to merge 1 commit into
alibaba:developfrom
FranzLi347:fix/bulk-update-overlap-window

Conversation

@FranzLi347

Copy link
Copy Markdown
Contributor

Problem

An ordered update batch can contain oplogs from both sides of the full-sync finish timestamp. If an older update fails with PathNotViable (code 28), MongoShake checks the timestamp of the last oplog in the batch. That can stop catch-up even when the failed update belongs to the full-sync overlap and is eligible for the existing ignore policy.

For example, replaying an update to a field inside a null array element can return Cannot create field 'state' in element [4: null].

Fix

  • Evaluate the existing update-error policy against the failed model's oplog timestamp, including the full-sync finish timestamp.
  • Resume the ordered bulk with the unattempted models. Keep the indexes aligned when a time-series update has already been handled via applyOps.
  • Return errors for updates outside the overlap and preserve write concern failures.

Verification

  • go build ./...
  • go test ./executor -run '^(TestBulkUpdateOverlapWindow|TestBulkUpdateAllApplyOps|TestIgnoreErrorBranches|TestExecutorMixed61DoesNotComplete|TestLazyWriters)$' -count=1
  • The cross-boundary regression fails on the upstream base and passes with the fix. The tests also cover a post-window update, a missing window, a write concern failure, and model-index mapping after applyOps.

An ordered bulk can straddle the end of full sync. Apply the existing
update-error policy to the failed oplog's timestamp, then replay the
unattempted models in order. Keep write concern failures visible.
@FranzLi347 FranzLi347 changed the title fix: use failed update timestamps during full-sync oplog replay fix: skip PathNotViable in the full-sync oplog window Nov 26, 2026
@zhongli-james
zhongli-james self-requested a review November 26, 2026 06:49
@zhongli-james

Copy link
Copy Markdown
Collaborator

Reviewed at 3bb9434 against develop a19ab1b. Verified locally: build/vet clean, the five cited tests pass, the new test fails 3 of 5 subtests on the base for the stated reasons, and the full ./executor package passes on MongoDB 7.0.48 and 8.0.10. The fix is correct: per-failed-oplog timestamps match SingleWriter's existing policy, and modelOplogs also fixes the dup-key/shard-key fallback slicing when applyOps skips records.

Approve with minor comments:

  1. One delta to confirm: the ignore branch now retries the tail as a bulk instead of SingleWriter, which verified MatchedCount (executor/db_writer_single.go:407, :413). With the default incr_sync.executor.upsert = false, a tail update matching 0 documents now passes silently where it previously errored. Reachability is narrow and the primary bulk path has the same exposure, so this is likely fine — please confirm it is intended.
  2. Test sensitivity: in the applyOps case both oplogs[1] and modelOplogs[1] fall inside the window, so mutating modelOplogs[index] back to oplogs[index] keeps the test green (checked locally). Making the two mappings straddle fullFinishTs would pin this.
  3. The new test is mock-only, but ./executor is not in CI's no-MongoDB group, so CI never runs it. A scoped -run '^TestBulkUpdateOverlapWindow$' entry costs one line.

Follow-up (pre-existing, worth a separate issue): doUpdateOnInsert has the same batch-last-timestamp check (executor/db_writer_bulk.go:328), and its ignore branch return nil (:335) drops the unattempted tail of an ordered bulk.

@zhongli-james zhongli-james self-assigned this Nov 27, 2026

This branch has not been deployed

No deployments
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.

2 participants