@@ -27,16 +27,6 @@ transaction is committed. If any operation in the transaction returns an
27
27
error, the driver cancels the transaction and discards all data changes
28
28
before they ever become visible.
29
29
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
-
40
30
When using the {+driver-short+}, you can create a new session from a
41
31
``MongoClient`` instance as a ``ClientSession`` type. We recommend that you reuse
42
32
your client for multiple sessions and transactions instead of
@@ -54,6 +44,36 @@ instantiating a new client each time.
54
44
You must include the ``session`` as a parameter for any operations that you
55
45
want to include in a transaction.
56
46
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
+
57
77
Methods
58
78
-------
59
79
0 commit comments