Skip to content

Commit 6c9b182

Browse files
committed
DOCSP-47041: Causal consistency
1 parent 52989b6 commit 6c9b182

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

source/crud/transactions.txt

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,6 @@ transaction is committed. If any operation in the transaction returns an
2727
error, the driver cancels the transaction and discards all data changes
2828
before they ever become visible.
2929

30-
In MongoDB, transactions run within logical **sessions**. A
31-
:manual:`session </reference/server-sessions/>` is a grouping of related
32-
read or write operations that you intend to run sequentially. Sessions
33-
enable :manual:`causal consistency
34-
</core/read-isolation-consistency-recency/#causal-consistency>` for a
35-
group of operations or allow you to execute operations in an
36-
:website:`ACID transaction </basics/acid-transactions>`. MongoDB
37-
guarantees that the data involved in your transaction operations remains
38-
consistent, even if the operations encounter unexpected errors.
39-
4030
When using the {+driver-short+}, you can create a new session from a
4131
``MongoClient`` instance as a ``ClientSession`` type. We recommend that you reuse
4232
your client for multiple sessions and transactions instead of
@@ -54,6 +44,36 @@ instantiating a new client each time.
5444
You must include the ``session`` as a parameter for any operations that you
5545
want to include in a transaction.
5646

47+
Causal Consistency
48+
~~~~~~~~~~~~~~~~~~
49+
50+
In MongoDB, transactions run within logical **sessions**. A
51+
session is a grouping of related read or write operations that you
52+
intend to run sequentially.
53+
54+
MongoDB enables **causal consistency** in client sessions, which allows
55+
you to execute operations in an :website:`ACID transaction </basics/acid-transactions>`.
56+
The causal consistency model guarantees that operations within a session
57+
run in a causal order. Additionally, clients observe results that
58+
are consistent with the causal relationships, or the dependencies between
59+
operations. If you perform a series of operations where one operation
60+
logically depends on the result of another, any subsequent
61+
reads reflect the dependent relationship.
62+
63+
In a causally consistent session, MongoDB ensures a
64+
causal relationship between the following operations:
65+
66+
- Read operations that have a ``MAJORITY`` read concern
67+
- Write operations that have a ``MAJORITY`` write concern
68+
69+
.. tip::
70+
71+
To learn more about the concepts mentioned in this section, see the
72+
following {+mdb-server+} manual entries:
73+
74+
- :manual:`Server Sessions </reference/server-sessions/>`
75+
- :manual:`Causal Consistency </core/read-isolation-consistency-recency/#causal-consistency>`
76+
5777
Methods
5878
-------
5979

0 commit comments

Comments
 (0)