0
0
MongoDBquery~20 mins

Causal consistency concept in MongoDB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Causal Consistency Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding causal consistency in MongoDB

Which statement best describes causal consistency in MongoDB?

AOperations that are causally related are seen by clients in the same order, but unrelated operations may be seen in different orders.
BOperations are only visible to the client that performed them until a manual refresh.
COperations are seen by all clients in the exact order they were performed globally.
DAll operations are immediately visible to all clients without delay.
Attempts:
2 left
💡 Hint

Think about how related changes should appear in order to maintain logical flow.

query_result
intermediate
2:00remaining
Effect of causal consistency on read operations

Given a MongoDB replica set with causal consistency enabled, if a client writes a document and then reads it immediately, what will the read operation return?

AThe read will return null until the write is acknowledged by all replicas.
BThe read may return an older version if the write has not propagated yet.
CThe read will fail with a consistency error.
DThe read will always return the latest written document.
Attempts:
2 left
💡 Hint

Consider what causal consistency guarantees about visibility of your own writes.

📝 Syntax
advanced
2:00remaining
Enabling causal consistency in MongoDB sessions

Which of the following code snippets correctly enables causal consistency for a MongoDB session in Node.js?

MongoDB
const session = client.startSession({ /* options here */ });
Aconst session = client.startSession({ enableCausalConsistency: true });
Bconst session = client.startSession({ causal_consistency: true });
Cconst session = client.startSession({ causalConsistency: true });
Dconst session = client.startSession({ causalConsistencyEnabled: true });
Attempts:
2 left
💡 Hint

Check the exact option name for enabling causal consistency in the MongoDB Node.js driver.

optimization
advanced
2:00remaining
Optimizing read preference with causal consistency

When using causal consistency in MongoDB, which read preference setting optimizes for reading your own writes while allowing reads from secondary replicas?

ARead preference set to <code>primary</code> only.
BRead preference set to <code>primaryPreferred</code>.
CRead preference set to <code>secondaryPreferred</code>.
DRead preference set to <code>secondary</code> only.
Attempts:
2 left
💡 Hint

Think about a setting that prefers primary but can fall back to secondary.

🔧 Debug
expert
3:00remaining
Diagnosing causal consistency violation in MongoDB

You observe that a client sometimes reads stale data that does not reflect its previous writes, despite using causal consistency sessions. Which is the most likely cause?

AThe client is not using the same session for the write and subsequent read operations.
BThe MongoDB cluster does not support causal consistency.
CThe write concern is set to <code>w: 0</code> causing writes to be unacknowledged.
DThe client is using read preference <code>primary</code> instead of <code>secondary</code>.
Attempts:
2 left
💡 Hint

Consider how sessions relate to causal consistency guarantees.