Is the Cosmos DB documentation example on session consistency misleading?

AZOK 0 Reputation points
2025-08-01T14:16:57.7366667+00:00

https://learn.microsoft.com/en-us/azure/cosmos-db/consistency-levels#session-consistency

The Cosmos DB documentation example on session consistency states:

Whereas the "Australia East" region is using "Session B" so, it receives data later but in the same order as the writes.

In the example there is a single writer writing in session A, and a reader reading in session B in another region. The quote implies that there is some sort of ordering guarantee for the session B reader? I would have assumed to see eventual consistency for the session B reader, i.e. the writes may end up being read in an incorrect order. Which is correct?

Continuing with the same example, does the session consistency level include the consistent prefix guarantee? Is the session B reader guaranteed to see consistent prefix reads? I believe one can explicitly set a read request to use a lower consistency level, so I should be able to get consistent prefix guarantees outside of a session at least by explicitly requesting it, if it isn't included by default?

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
{count} votes

1 answer

Sort by: Most helpful
  1. Mahesh Kurva 6,850 Reputation points Microsoft External Staff Moderator
    2025-08-01T22:08:33.74+00:00

    Hi AZOK ,

    GreetingS!!

    It sounds like you’re trying to clarify a couple of points regarding the session consistency example in Azure Cosmos DB documentation.

    What Session Consistency Guarantees

    Session consistency ensures the following for a single client session:

    • Read-your-writes: A client will always see its own writes.
    • Monotonic reads: Once a client reads a value, it will not see an older value in subsequent reads.
    • Monotonic writes: Writes are serialized in the order they were issued by the client.
    • Writes-follow-reads: A write operation following a read is guaranteed to be based on the latest read.

    The Confusion in the Documentation

    The documentation example says:

    "Whereas the 'Australia East' region is using 'Session B' so, it receives data later but in the same order as the writes."

    This can be misleading if interpreted as a cross-session guarantee. Here's why:

    • Session B is a different session from the writer's session (Session A).
    • Session consistency does not guarantee ordering across sessios.
    • Therefore, Session B may see writes out of order or not at all, unless it happens to read after the data has propagated and is available in the correct order.

    So you're correct: Session B should not expect consistent prefix or ordered reads unless it is the same session as the writer.

    Does Session Consistency Include Consistent Prefix?

    No, session consistency does not include consistent prefix guarantees for other sessions. The consistent prefix level ensures that all clients see writes in the order they were committed, but it does not guarantee read-your-writes or monotonic reads.

    Hope this helps. Do let us know if you any further queries.

    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.