-
Notifications
You must be signed in to change notification settings - Fork 788
/
Copy pathreadconcern.xml
315 lines (291 loc) · 11.1 KB
/
readconcern.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<reference xml:id="class.mongodb-driver-readconcern" role="class" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>The MongoDB\Driver\ReadConcern class</title>
<titleabbrev>MongoDB\Driver\ReadConcern</titleabbrev>
<partintro>
<!-- {{{ MongoDB\Driver\ReadConcern intro -->
<section xml:id="mongodb-driver-readconcern.intro">
&reftitle.intro;
<para>
<classname>MongoDB\Driver\ReadConcern</classname> controls the level of
isolation for read operations for replica sets and replica set shards. This
option requires MongoDB 3.2 or later.
</para>
</section>
<!-- }}} -->
<section xml:id="mongodb-driver-readconcern.synopsis">
&reftitle.classsynopsis;
<!-- {{{ Synopsis -->
<classsynopsis>
<ooclass><classname>MongoDB\Driver\ReadConcern</classname></ooclass>
<!-- {{{ Class synopsis -->
<classsynopsisinfo>
<modifier>final</modifier>
<ooclass>
<classname>MongoDB\Driver\ReadConcern</classname>
</ooclass>
<oointerface>
<interfacename>MongoDB\BSON\Serializable</interfacename>
</oointerface>
<oointerface>
<interfacename>Serializable</interfacename>
</oointerface>
</classsynopsisinfo>
<!-- }}} -->
<classsynopsisinfo role="comment">&Constants;</classsynopsisinfo>
<fieldsynopsis>
<modifier>const</modifier>
<type>string</type>
<varname linkend="mongodb-driver-readconcern.constants.linearizable">MongoDB\Driver\ReadConcern::AVAILABLE</varname>
<initializer>"available"</initializer>
</fieldsynopsis>
<fieldsynopsis>
<modifier>const</modifier>
<type>string</type>
<varname linkend="mongodb-driver-readconcern.constants.linearizable">MongoDB\Driver\ReadConcern::LINEARIZABLE</varname>
<initializer>"linearizable"</initializer>
</fieldsynopsis>
<fieldsynopsis>
<modifier>const</modifier>
<type>string</type>
<varname linkend="mongodb-driver-readconcern.constants.local">MongoDB\Driver\ReadConcern::LOCAL</varname>
<initializer>"local"</initializer>
</fieldsynopsis>
<fieldsynopsis>
<modifier>const</modifier>
<type>string</type>
<varname linkend="mongodb-driver-readconcern.constants.majority">MongoDB\Driver\ReadConcern::MAJORITY</varname>
<initializer>"majority"</initializer>
</fieldsynopsis>
<fieldsynopsis>
<modifier>const</modifier>
<type>string</type>
<varname linkend="mongodb-driver-readconcern.constants.snapshot">MongoDB\Driver\ReadConcern::SNAPSHOT</varname>
<initializer>"snapshot"</initializer>
</fieldsynopsis>
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.mongodb-driver-readconcern')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" />
</classsynopsis>
<!-- }}} -->
</section>
<!-- {{{ MongoDB\Driver\ReadConcern constants -->
<section xml:id="mongodb-driver-readconcern.constants">
&reftitle.constants;
<variablelist>
<varlistentry xml:id="mongodb-driver-readconcern.constants.available">
<term><constant>MongoDB\Driver\ReadConcern::AVAILABLE</constant></term>
<listitem>
<para>
Default for reads against secondaries when
<literal>afterClusterTime</literal>and <literal>level</literal> are
unspecified.
</para>
<para>
The query returns the instance's most recent data. Provides no
guarantee that the data has been written to a majority of the replica set
members (i.e. may be rolled back).
</para>
<para>
For unsharded collections (including collections in a standalone
deployment or a replica set deployment), <literal>"local"</literal> and
<literal>"available"</literal> read concerns behave identically.
</para>
<para>
For a sharded cluster, <literal>"available"</literal> read concern
provides greater tolerance for partitions since it does not wait to
ensure consistency guarantees. However, a query with
<literal>"available"</literal> read concern may return orphan documents
if the shard is undergoing chunk migrations since the
<literal>"available"</literal> read concern, unlike
<literal>"local"</literal> read concern, does not contact the
shard's primary nor the config servers for updated metadata.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="mongodb-driver-readconcern.constants.linearizable">
<term><constant>MongoDB\Driver\ReadConcern::LINEARIZABLE</constant></term>
<listitem>
<para>
The query returns data that reflects all successful writes issued with a
write concern of <literal>"majority"</literal> <emphasis>and</emphasis>
acknowledged prior to the start of the read operation. For replica sets
that run with <literal>writeConcernMajorityJournalDefault</literal> set
to &true;, linearizable read concern returns data that will never be
rolled back.
</para>
<para>
With <literal>writeConcernMajorityJournalDefault</literal> set to
&false;, MongoDB will not wait for <literal>w: "majority"</literal>
writes to be durable before acknowledging the writes. As such,
<literal>"majority"</literal> write operations could possibly roll back
in the event of a loss of a replica set member.
</para>
<para>
You can specify linearizable read concern for read operations on the
primary only.
</para>
<para>
Linearizable read concern guarantees only apply if read
operations specify a query filter that uniquely identifies a single
document.
</para>
<tip>
<simpara>
Always use <literal>maxTimeMS</literal> with linearizable read concern
in case a majority of data bearing members are unavailable.
<literal>maxTimeMS</literal> ensures that the operation does not block
indefinitely and instead ensures that the operation returns an error if
the read concern cannot be fulfilled.
</simpara>
</tip>
<para>
Linearizable read concern requires MongoDB 3.4.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="mongodb-driver-readconcern.constants.local">
<term><constant>MongoDB\Driver\ReadConcern::LOCAL</constant></term>
<listitem>
<para>
Default for reads against primary if <literal>level</literal> is
unspecified and for reads against secondaries if <literal>level</literal>
is unspecified but <literal>afterClusterTime</literal> is specified.
</para>
<para>
The query returns the instance's most recent data. Provides no
guarantee that the data has been written to a majority of the replica set
members (i.e. may be rolled back).
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="mongodb-driver-readconcern.constants.majority">
<term><constant>MongoDB\Driver\ReadConcern::MAJORITY</constant></term>
<listitem>
<para>
The query returns the instance's most recent data acknowledged as
having been written to a majority of members in the replica set.
</para>
<para>
To use read concern level of <literal>"majority"</literal>, replica sets
must use WiredTiger storage engine and election protocol version 1.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="mongodb-driver-readconcern.constants.snapshot">
<term><constant>MongoDB\Driver\ReadConcern::SNAPSHOT</constant></term>
<listitem>
<para>
Read concern <literal>"snapshot"</literal> is available for
multi-document transactions, and starting in MongoDB 5.0, certain read
operations outside of multi-document transactions.
</para>
<para>
If the transaction is not part of a causally consistent session, upon
transaction commit with write concern <literal>"majority"</literal>, the
transaction operations are guaranteed to have read from a snapshot of
majority-committed data.
</para>
<para>
If the transaction is part of a causally consistent session, upon
transaction commit with write concern <literal>"majority"</literal>, the
transaction operations are guaranteed to have read from a snapshot of
majority-committed data that provides causal consistency with the
operation immediately preceding the transaction start.
</para>
<para>
Outside of multi-document transactions, read concern
<literal>"snapshot"</literal> is available on primaries and secondaries
for the following read operations: <literal>find</literal>,
<literal>aggregate</literal>, and <literal>distinct</literal> (on
unsharded collections). All other read commands prohibit
<literal>"snapshot"</literal>.
</para>
</listitem>
</varlistentry>
</variablelist>
</section>
<!-- }}} -->
<section role="changelog">
&reftitle.changelog;
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>PECL mongodb 1.11.0</entry>
<entry>
<para>
Added the <constant>MongoDB\Driver\ReadConcern::SNAPSHOT</constant>
constant.
</para>
</entry>
</row>
<row>
<entry>PECL mongodb 1.7.0</entry>
<entry>
Implements <interfacename>Serializable</interfacename>.
</entry>
</row>
<row>
<entry>PECL mongodb 1.4.0</entry>
<entry>
<para>
Added the <constant>MongoDB\Driver\ReadConcern::AVAILABLE</constant>
constant.
</para>
</entry>
</row>
<row>
<entry>PECL mongodb 1.2.0</entry>
<entry>
<para>
Added the
<constant>MongoDB\Driver\ReadConcern::LINEARIZABLE</constant>
constant.
</para>
<para>
Implements <interfacename>MongoDB\BSON\Serializable</interfacename>.
</para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</section>
<section xml:id="mongodb-driver-readconcern.seealso">
&reftitle.seealso;
<simplelist>
<member><link xlink:href="&url.mongodb.docs.readconcern;">Read Concern reference</link></member>
</simplelist>
</section>
</partintro>
&reference.mongodb.mongodb.driver.entities.readconcern;
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->