Skip to content

Commit 2644aac

Browse files
jason-price-mongodbjason-price-mongodb
andauthored
Docsp-23328 default read and write concern (#1410)
* DOCSP-23328-default-read-and-write-concern * DOCSP-23328-default-read-and-write-concern * DOCSP-23328-default-read-and-write-concern * DOCSP-23328-default-read-and-write-concern * DOCSP-23328-default-read-and-write-concern * DOCSP-23328-default-read-and-write-concern Co-authored-by: jason-price-mongodb <[email protected]>
1 parent b49290a commit 2644aac

File tree

1 file changed

+44
-31
lines changed

1 file changed

+44
-31
lines changed

source/reference/command/setDefaultRWConcern.txt

Lines changed: 44 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -340,54 +340,67 @@ The operation returns a document similar to the following:
340340
"defaultReadConcern" : {
341341
"level" : "majority"
342342
}
343-
344343

345344
Unset Global Default Read and Write Concern
346345
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
347346

348-
Consider a deployment with the following default read and write
349-
concern:
347+
You can:
348+
349+
- Unset the global default read concern.
350+
- Only unset the global default write concern if you haven't already
351+
set it.
352+
353+
For example, assume the global default read concern is set to
354+
:readconcern:`level: "majority" <"majority">`. To unset the global
355+
default read concern, use an empty document ``{}``:
356+
357+
.. code-block:: javascript
358+
359+
db.adminCommand( {
360+
"setDefaultRWConcern" : 1,
361+
"defaultReadConcern" : {}
362+
} )
350363

364+
The operation returns a document that indicates the operation was
365+
successful:
351366

352367
.. code-block:: javascript
353368
:copyable: false
354369

355370
{
356-
"defaultWriteConcern" : {
357-
"w" : "majority"
358-
},
359-
"defaultReadConcern" : {
360-
"level" : "majority"
361-
},
362-
"updateOpTime" : Timestamp(1586290895, 1),
363-
"updateWallClockTime" : ISODate("2020-04-07T20:21:41.849Z"),
364-
"localUpdateWallClockTime" : ISODate("2020-04-07T20:21:41.862Z"),
365-
"ok" : 1,
366-
"$clusterTime" : { ... }
367-
"operationTime" : Timestamp(1586290925, 1)
371+
defaultReadConcern: { level: 'local' },
372+
defaultWriteConcern: { w: 2, wtimeout: 0 },
373+
updateOpTime: Timestamp({ t: 1656696934, i: 1 }),
374+
updateWallClockTime: ISODate("2022-07-01T17:35:40.578Z"),
375+
defaultWriteConcernSource: 'global',
376+
defaultReadConcernSource: 'implicit',
377+
localUpdateWallClockTime: ISODate("2022-07-01T17:35:40.578Z"),
378+
ok: 1,
379+
'$clusterTime': {
380+
...
381+
},
382+
operationTime: Timestamp({ t: 1656632593, i: 1 })
368383
}
369384

370-
The following operation unsets the global default read and write
371-
concern settings:
385+
You can only unset the global default write concern if you haven't
386+
already set it.
387+
388+
To unset the global default write concern, use an empty document ``{}``:
372389

373390
.. code-block:: javascript
374391

375-
db.adminCommand({
376-
"setDefaultRWConcern" : 1,
377-
"defaultReadConcern" : {},
378-
"defaultWriteConcern" : {}
379-
})
392+
db.adminCommand( {
393+
"setDefaultRWConcern" : 1,
394+
"defaultWriteConcern" : {}
395+
} )
380396

381-
The operation returns a document similar to the following:
397+
If the global default write concern is:
398+
399+
- Unset, the operation succeeds.
400+
- Already set, the operation returns the following error.
382401

383402
.. code-block:: javascript
384403
:copyable: false
385404

386-
{
387-
"updateOpTime" : Timestamp(1586290895, 1),
388-
"updateWallClockTime" : ISODate("2020-04-07T20:21:41.849Z"),
389-
"localUpdateWallClockTime" : ISODate("2020-04-07T20:21:41.862Z"),
390-
"ok" : 1,
391-
"$clusterTime" : { ... }
392-
"operationTime" : Timestamp(1586290925, 1)
393-
}
405+
MongoServerError: The global default write concern cannot be unset
406+
once it is set.

0 commit comments

Comments
 (0)