Consider a MongoDB collection orders where a document was just inserted but not yet replicated to secondaries. What will be the result of this query with readConcern: 'local'?
db.orders.find({}).readConcern('local').toArray()db.orders.find({}).readConcern('local').toArray()Think about what 'local' means: reading from the node's own data without waiting for replication.
The 'local' read concern returns data from the node's own view, including unreplicated writes. It does not wait for replication.
In a MongoDB replica set, a document was inserted but has not yet been replicated to the majority of nodes. What will a query with readConcern: 'majority' return?
db.orders.find({}).readConcern('majority').toArray()db.orders.find({}).readConcern('majority').toArray()Consider what 'majority' means for data visibility in a replica set.
The 'majority' read concern ensures that the query returns data that has been acknowledged by the majority of replica set members, so unreplicated writes are not visible yet.
Within a multi-document transaction using readConcern: 'snapshot', what is the visibility of data changes made outside the transaction after it started?
session.startTransaction({readConcern: {level: 'snapshot'}});
db.orders.find({}).toArray();Think about what 'snapshot' read concern guarantees inside transactions.
'Snapshot' read concern provides a stable view of data as it existed at the start of the transaction, so changes made outside after the start are not visible.
You want to design a MongoDB application that prioritizes the fastest possible reads, even if it means reading unreplicated or stale data. Which read concern level should you choose?
Consider which read concern returns data fastest without waiting for replication.
'Local' read concern returns data immediately from the node's own view, providing the lowest latency but possibly reading unreplicated data.
During a network partition in a MongoDB replica set, which of the following best describes the behavior of queries using readConcern: 'majority'?
Think about how 'majority' read concern depends on replication acknowledgments.
'Majority' read concern requires confirmation that data is replicated to most nodes. During partitions, this may cause queries to block or fail if majority cannot be confirmed.