C100DEV CRUD Operations Practice Question
An analytics job updates counters in the 'metrics' collection with db.metrics.updateOne({ metric: "visits" }, { $inc: { count: 1 } }). The job runs with write concern w:1 against a three-node replica set, and a failover occurs immediately after the primary acknowledges a write. The developer reports that a counter increment appears to be lost. Which statement best explains this outcome?
⚠ Common exam trap
The trap here is treating w:1 as durable across failover, when it only guarantees the primary applied the write locally before acknowledging.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
With w:1 the primary acknowledged before the update was replicated, so if it stepped down and rolled back, the increment could be undone on the new primary.
Write concern w:1 confirms the write only on the primary. If that primary fails before the operation reaches any secondary, the new primary never has the change, and the old primary rolls it back upon rejoining, so an acknowledged increment can disappear. Stronger write concern such as majority prevents this by requiring replication before acknowledgement.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
$inc is not atomic on a replica set, so two nodes can apply the increment independently and produce a divergent count value.
Why it's wrong here
$inc is an atomic single-document update operator regardless of topology. On a replica set the operation is applied once on the primary and then replicated through the oplog to secondaries, so nodes do not independently compute the increment. This option misstates how replication and atomic updates interact, and it is not the reason a count appears lost.
- ✗
The update used an equality filter on 'metric', so the query planner could not use an index and the write was silently skipped under load.
Why it's wrong here
A missing index affects query performance, not whether a write is applied. The update would still execute and modify the matching document even with a collection scan. There is no mechanism by which an unindexed equality filter causes a write to be silently skipped, so this does not explain the lost increment.
- ✓
With w:1 the primary acknowledged before the update was replicated, so if it stepped down and rolled back, the increment could be undone on the new primary.
Why this is correct
Write concern w:1 acknowledges after the primary applies the write to its own journal, not after replication to secondaries. If the primary steps down before the operation replicates and the new primary never received it, the old primary rolls the write back when it rejoins. That rollback is exactly how an acknowledged increment can appear lost under failover.
- ✗
Because the collection has no unique index on 'metric', the increment was applied to multiple documents and the count became ambiguous.
Why it's wrong here
updateOne modifies at most one matching document, so the absence of a unique index cannot cause multiple counters to be incremented by this statement. Even if several documents shared the metric value, only one would be updated. This option misattributes the symptom to indexing rather than to replication acknowledgement semantics.
About these practice questions
Courseiva writes every C100DEV question from scratch — 259 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official MongoDB exam blueprint
This C100DEV practice question is part of Courseiva's free MongoDB certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the C100DEV exam.