1MONGOC_WRITE_CONCERN_T(3) libmongoc MONGOC_WRITE_CONCERN_T(3)
2
3
4
5Write Concern abstraction
6
8 mongoc_write_concern_t tells the driver what level of acknowledgement
9 to await from the server. The default, MONGOC_WRITE_CONCERN_W_DEFAULT,
10 is right for the great majority of applications.
11
12 You can specify a write concern on connection objects, database ob‐
13 jects, collection objects, or per-operation. Data-modifying operations
14 typically use the write concern of the object they operate on, and
15 check the server response for a write concern error or write concern
16 timeout. For example, mongoc_collection_drop_index() uses the collec‐
17 tion's write concern, and a write concern error or timeout in the re‐
18 sponse is considered a failure.
19
20 Exceptions to this principle are the generic command functions:
21
22 • mongoc_client_command()
23
24 • mongoc_client_command_simple()
25
26 • mongoc_database_command()
27
28 • mongoc_database_command_simple()
29
30 • mongoc_collection_command()
31
32 • mongoc_collection_command_simple()
33
34 These generic command functions do not automatically apply a write con‐
35 cern, and they do not check the server response for a write concern er‐
36 ror or write concern timeout.
37
38 See Write Concern on the MongoDB website for more information.
39
41 Set the write concern level with mongoc_write_concern_set_w().
42
43 ┌───────────────────────────┬────────────────────────────┐
44 │MONGOC_WRITE_CONCERN_W_DE‐ │ By default, writes block │
45 │FAULT (1) │ awaiting acknowledgement │
46 │ │ from MongoDB. Acknowledged │
47 │ │ write concern allows │
48 │ │ clients to catch network, │
49 │ │ duplicate key, and other │
50 │ │ errors. │
51 ├───────────────────────────┼────────────────────────────┤
52 │MONGOC_WRITE_CONCERN_W_UN‐ │ With this write concern, │
53 │ACKNOWLEDGED (0) │ MongoDB does not acknowl‐ │
54 │ │ edge the receipt of write │
55 │ │ operation. Unacknowledged │
56 │ │ is similar to errors ig‐ │
57 │ │ nored; however, mongoc at‐ │
58 │ │ tempts to receive and han‐ │
59 │ │ dle network errors when │
60 │ │ possible. │
61 └───────────────────────────┴────────────────────────────┘
62
63
64
65
66
67 │MONGOC_WRITE_CONCERN_W_MA‐ │ Block until a write has │
68 │JORITY (majority) │ been propagated to a ma‐ │
69 │ │ jority of the nodes in the │
70 │ │ replica set. │
71 ├───────────────────────────┼────────────────────────────┤
72 │n │ Block until a write has │
73 │ │ been propagated to at │
74 │ │ least n nodes in the │
75 │ │ replica set. │
76 └───────────────────────────┴────────────────────────────┘
77
79 The write concern MONGOC_WRITE_CONCERN_W_ERRORS_IGNORED (value -1) is a
80 deprecated synonym for MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED (value 0),
81 and will be removed in the next major release.
82
83 mongoc_write_concern_set_fsync() is deprecated.
84
86 MongoDB, Inc
87
89 2017-present, MongoDB, Inc
90
91
92
93
941.25.1 Nov 08, 2023 MONGOC_WRITE_CONCERN_T(3)