A query with read concern
"local" returns data from the instance
with no guarantee that the data has been written to a majority of the
replica set members (i.e. may be rolled back).
"local" is the default for:
- read operations against primary
- read operations against secondaries if the reads are associated with causally consistent sessions.
Regardless of the read concern level, the most recent data on a node may not reflect the most recent version of the data in the system.
"local" is available for use with or without
causally consistent sessions and transactions.
"local" and Transactions¶
You set the read concern at the transaction level, not at the individual operation level. To set the read concern for transactions, see Transactions and Read Concern.
Starting in MongoDB 4.4, with feature compatibility version
"4.4" or greater, you can create
collections and indexes
inside a transaction. If explicitly creating a collection or an
index, the transaction must use read concern
creation of a collection can use any of the read concerns available
Consider the following timeline of a write operation Write 0 to a three member replica set:
For simplification, the example assumes:
- All writes prior to Write 0 have been successfully replicated to all members.
- Write prev is the previous write before Write 0.
- No other writes have occured after Write 0.
Most Recent Write
Most Recent w: "majority" write
Primary applies Write 0
Primary: Write 0