• "available"

Read Concern "available"

New in version 3.6.

A query with read concern “available” returns data from the instancewith no guarantee that the data has been written to a majority of thereplica set members (i.e. may be rolled back).

Read concern “available” is the default for reads against secondariesif the reads are not associated with causally consistent sessions.

For a sharded cluster, "available" read concern providesgreater tolerance for partitions since it does not wait to ensureconsistency guarantees. However, a query with"available" read concern may return orphaneddocuments if the shard is undergoing chunkmigrations since the "available" read concern, unlike"local" read concern, does not contact the shard’sprimary nor the config servers for updated metadata.

For unsharded collections (including collections in a standalonedeployment or a replica set deployment), "local" and"available" read concerns behave identically.

Regardless of the read concern level, the most recent data on anode may not reflect the most recent version of the data in the system.

See also

orphanCleanupDelaySecs

Causally Consistent Sessions

Read concern available is unavailable for use withcausally consistent sessions.

Example

Consider the following timeline of a write operation Write0 toa three member replica set:

Note

For simplification, the example assumes:

  • All writes prior to Write0 have been successfullyreplicated to all members.
  • Writeprev is the previous write before Write0.
  • No other writes have occured after Write0.

Timeline of a write operation to a three member replica set.

TimeEventMost Recent WriteMost Recent w: “majority” write
t0Primary applies Write0Primary: Write0Secondary1: WriteprevSecondary2: WriteprevPrimary: WriteprevSecondary1: WriteprevSecondary2: Writeprev
t1Secondary1 applies write0Primary: Write0Secondary1: Write0Secondary2: WriteprevPrimary: WriteprevSecondary1: WriteprevSecondary2: Writeprev
t2Secondary2 applies write0Primary: Write0Secondary1: Write0Secondary2: Write0Primary: WriteprevSecondary1: WriteprevSecondary2: Writeprev
t3Primary is aware of successful replication to Secondary1 and sends acknowledgement to clientPrimary: Write0Secondary1: Write0Secondary2: Write0Primary: Write0Secondary1: WriteprevSecondary2: Writeprev
t4Primary is aware of successful replication to Secondary2Primary: Write0Secondary1: Write0Secondary2: Write0Primary: Write0Secondary1: WriteprevSecondary2: Writeprev
t5Secondary1 receives notice (through regular replication mechanism) to update its snapshot of its most recent w: “majority” writePrimary: Write0Secondary1: Write0Secondary2: Write0Primary: Write0Secondary1: Write0Secondary2: Writeprev
t6Secondary2 receives notice (through regular replication mechanism) to update its snapshot of its most recent w: “majority” writePrimary: Write0Secondary1: Write0Secondary2: Write0Primary: Write0Secondary1: Write0Secondary2: Write0

Then, the following tables summarizes the state of the data that a readoperation with "available" read concern would see attime T.

Timeline of a write operation to a three member replica set.

Read TargetTime TState of Data
PrimaryAfter t0Data reflects Write0.
Secondary1Before t1Data reflects Writeprev
Secondary1After t1Data reflects Write0
Secondary2Before t2Data reflects Writeprev
Secondary2After t2Data reflects Write0