Pinned event-mongodb schema version writes and notification failure boundaries
Parent: Change Data Capture Patterns · Published reference · snapshot 2026-11-02
↓ Facts as markdownall context files
Source-anchored research for Pinned event-mongodb schema version writes and notification failure boundaries. Run status: COMPLETED.
These notes link each claim to its source. Some citations identify archived research reports that are no longer hosted on this site. A published reference means the content is available; it does not certify independent review or accuracy.Read the editorial policy and follow the sources before relying on a claim.
Definitions
- The read-check-replace sequence is not a database compare-and-swap on the version: `Get` reads by `_id`, while `p.collection.ReplaceOne` filters only by `_id`. Inference from those predicates: a concurrent writer can replace the record between the check and replacement, so this method alone does not establish atomic monotonic version enforcement. (low confidence) [source]
Problems, failure modes and limitations
- In the pinned implementation, `Set` calls `schema.Validate()` before checking whether the provider is closed. It then calls `p.Get(ctx, schema.Name)` and returns its error. The downgrade predicate is `existing != nil && schema.Version < existing.Version`; equal versions are permitted. (medium confidence) [source 1] [source 2]
- After the version check, `Set` converts the supplied schema, assigns `m.UpdatedAt` from `time.Now()`, assigns `m.CreatedAt` for a new record or preserves the existing value, and calls `p.collection.ReplaceOne` with only `_id` in the filter and `options.Replace().SetUpsert(true)`. A replacement error returns before notification. (low confidence) [source]
- After a successful replacement, Set constructs a SchemaChangeEvent from Name, Version and the same timestamp, attempts local watcher sends under an RLock using select with a default branch, releases the lock, and invokes a non-nil publisher. A channel that cannot accept the send loses that notification without an error from this loop. (low confidence) [source]
- A publisher error is returned directly from Set after the replacement and local watcher-send attempts; the method contains no rollback, retry or persisted pending-notification operation for that error path. This is a source-level control-flow observation, not an executed failure test. (low confidence) [source]
- Coverage limit of the two inspected pinned schema test files: neither contains a concurrent version-write assertion, a failing publisher callback scenario, watcher buffer saturation, crash recovery, or durable notification replay. The inspected success fixtures therefore do not establish atomic concurrent-version enforcement or durable notification delivery. (medium confidence) [source 1] [source 2]
Comparisons and alternatives
- `Delete` checks the closed flag and calls `p.collection.DeleteOne` using `_id`; it wraps database errors and otherwise returns nil without inspecting the deletion count. Unlike `Set`, its body does not send to local watchers or invoke the publisher. (low confidence) [source]
Facts and statements
- `Watch` rejects a closed provider, creates a local channel with capacity `100`, appends it to `p.watchers`, and starts a goroutine that waits for context cancellation or `p.closeChan`. The goroutine removes the channel under the mutex and closes it. This method does not open a MongoDB change stream or replay persisted notifications. (low confidence) [source]
- As source observations, the sequential `TestIntegrationSetVersionDowngrade` fixture sets version `5`, expects `ErrVersionDowngrade` for version `3`, permits another version `5`, and permits version `6`. `TestIntegrationSetPreservesCreatedAt` asserts preserved creation time and advancing update time after sequential writes. These assertions are not execution results from this research pass. (medium confidence) [source 1] [source 2]
- As source observations, `TestIntegrationSetGetDelete` checks a missing record, writes a schema, checks retrieved fields and nonzero timestamps, deletes it, and expects a missing record afterward. The unit fixtures separately assert closed-provider guards and rejection of an empty schema name before server interaction; they do not execute those integration operations. (medium confidence) [source 1] [source 2]
- The success-path fixture `TestIntegrationPublisherInvokedOnSet` asserts one callback invocation with event name `evt` and version `2`. `TestIntegrationWatchReceivesChange` uses a nil publisher, asserts a local notification for `watched` at version `7`, and checks channel closure after cancellation. These are fixture assertions, not observed test outcomes. (low confidence) [source]
Children
- No children recorded.