Q38: What is Write Concern in MongoDB (w: 1, w: majority, j: true)?

Write Concern describes the level of acknowledgment requested from MongoDB for write operations:

  • w: 1: Write acknowledged by Primary node only.
  • w: 'majority': Write acknowledged by a majority of replica set data-bearing nodes.
  • j: true: Write committed to on-disk journal file before returning success.
Key Takeaways
  • w: majority guarantees protection against rollback during failovers.

  • j: true ensures write durability across sudden crash events.

Knowledge Check

Which write concern setting guarantees that a write will NOT be rolled back if the Primary node crashes immediately after writing?