Read guarantees

What each read concern sees and when to read from replicas.

Choose which data a read sees with the read concern and which replica it reads from with the read preference.

Requirements

  • A connection with a user that has read on the database.

Read concern

ValueWhat it sees
local, availableData confirmed by a majority, like majority.
majorityData confirmed by a majority.
snapshotA snapshot at a timestamp, also across ranges.

Read from replicas

JavaScript
db.orders.find({ status: "paid" }).readPref("nearest");

With secondary or nearest, the router picks the nearest replica whose closed timestamp covers the read. The leader publishes that timestamp about 3 seconds behind its clock.

Check

A read in a session with causalConsistency sees what the same session wrote before, also when it goes to another replica.

Common problems

  • A replica read does not see a write from less than about 3 seconds ago. Read from the primary or use a session with causalConsistency.

See also