0
0
MongoDBquery~20 mins

Write concern and data durability in MongoDB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Write Concern Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Write Concern Levels

Which write concern level ensures that the write operation is acknowledged by the primary and at least one secondary replica before returning success?

A"w: 2" (Acknowledgment from primary and at least one secondary)
B"w: 1" (Acknowledgment from primary only)
C"w: 0" (No acknowledgment required)
D"w: majority" (Acknowledgment from majority of replica set members)
Attempts:
2 left
💡 Hint

Think about how many nodes must confirm the write for durability.

query_result
intermediate
2:00remaining
Result of Write Concern with w:0

What is the result of a MongoDB insert operation with write concern set to { w: 0 }?

MongoDB
db.collection.insertOne({name: "Alice"}, {writeConcern: {w: 0}})
AThe operation returns immediately without any acknowledgment.
BThe operation waits for acknowledgment from the primary node.
CThe operation waits for acknowledgment from all replica set members.
DThe operation throws an error due to invalid write concern.
Attempts:
2 left
💡 Hint

Consider what w: 0 means for acknowledgment.

📝 Syntax
advanced
2:00remaining
Correct Write Concern Syntax for Majority

Which of the following MongoDB write concern options correctly requests acknowledgment from the majority of replica set members?

A{ writeConcern: { w: "majority", j: true } }
B{ writeConcern: { w: majority } }
C{ writeConcern: { w: 'majority' } }
D{ writeConcern: { w: "majority" } }
Attempts:
2 left
💡 Hint

Check the correct way to specify string values in JavaScript objects.

optimization
advanced
2:00remaining
Optimizing Write Concern for Performance and Durability

You want to optimize a MongoDB write operation to balance durability and performance. Which write concern setting is the best choice?

A{ w: 0, j: false }
B{ w: 1, j: true }
C{ w: 1, j: false }
D{ w: "majority", j: true }
Attempts:
2 left
💡 Hint

Consider acknowledgment from primary and journaling for durability.

🔧 Debug
expert
2:00remaining
Diagnosing Write Concern Timeout Error

A MongoDB write operation with { w: 3, wtimeout: 1000 } fails with a write concern timeout error. What is the most likely cause?

AThe write operation syntax is incorrect and causes a timeout.
BThe primary node is down, so no acknowledgment is possible.
CThe replica set has fewer than 3 members available to acknowledge the write.
DThe write concern timeout value is too high, causing delay.
Attempts:
2 left
💡 Hint

Think about how many nodes must confirm the write and the replica set size.