|
| 1 | +MongoDB enables **causal consistency** in client sessions. |
| 2 | +The causal consistency model guarantees that operations within a session |
| 3 | +run in a causal order. Clients observe results that are consistent |
| 4 | +with the causal relationships, or the dependencies between |
| 5 | +operations. For example, if you perform a series of operations where |
| 6 | +one operation logically depends on the result of another, any subsequent |
| 7 | +reads reflect the dependent relationship. |
| 8 | + |
| 9 | +The following table describes the guarantees that causally |
| 10 | +consistent sessions provide: |
| 11 | + |
| 12 | +.. list-table:: |
| 13 | + :widths: 40 60 |
| 14 | + :header-rows: 1 |
| 15 | + |
| 16 | + * - Guarantee |
| 17 | + - Description |
| 18 | + |
| 19 | + * - Read your writes |
| 20 | + - Read operations reflect the results of preceding write operations. |
| 21 | + |
| 22 | + * - Monotonic reads |
| 23 | + - Read operations do not return results that reflect an earlier data state than |
| 24 | + a preceding read operation. |
| 25 | + |
| 26 | + * - Monotonic writes |
| 27 | + - If a write operation must precede other write operations, the driver |
| 28 | + runs this write operation first. |
| 29 | + |
| 30 | + For example, if you call |insert-one-method| to insert a document, then call |
| 31 | + |update-one-method| to modify the inserted document, the driver runs the |
| 32 | + insert operation first. |
| 33 | + |
| 34 | + * - Writes follow reads |
| 35 | + - If a write operation must follow other read operations, the driver runs |
| 36 | + the read operations first. |
| 37 | + |
| 38 | + For example, if you call |find-one-method| to retrieve a document, then call |
| 39 | + |delete-one-method| to delete the retrieved document, the driver runs the find |
| 40 | + operation first. |
| 41 | + |
| 42 | +In a causally consistent session, MongoDB ensures a |
| 43 | +causal relationship between the following operations: |
| 44 | + |
| 45 | +- Read operations that have a |majority-rc| read concern |
| 46 | +- Write operations that have a |majority-wc| write concern |
| 47 | + |
| 48 | +.. tip:: |
| 49 | + |
| 50 | + To learn more about the concepts mentioned in this section, see the |
| 51 | + following {+mdb-server+} manual entries: |
| 52 | + |
| 53 | + - :manual:`Causal Consistency </core/read-isolation-consistency-recency/#causal-consistency>` |
| 54 | + - :manual:`Causal Consistency and Read and Write Concerns </core/causal-consistency-read-write-concerns/>` |
0 commit comments