Skip to content

Commit 06f84a8

Browse files
authored
DOCSP-22105 User Write Block (#1069)
* DOCSP-22105 Database Command * DOCSP-22105 Auth privileges * DOCSP-22105 Example * DOCSP-22105 Auth privileges * DOCSP-22105 Privilege updates * DOCSP-22105 Expands example * DOCSP-22105 Expands example * DOCSP-22105 Fixes per Dave * DOCSP-22105 Fixes per Dave * DOCSP-22105 Expands example
1 parent d289ee0 commit 06f84a8

File tree

4 files changed

+130
-0
lines changed

4 files changed

+130
-0
lines changed

source/reference/built-in-roles.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ Backup and Restoration Roles
589589
- :authaction:`getParameter`
590590
- :authaction:`listDatabases`
591591
- :authaction:`serverStatus` (Starting in MongoDB 4.2)
592+
- :authaction:`setUserWriteBlockMode` (Starting in MongoDB 6.0)
592593

593594
Provides the :authaction:`find` action on the following:
594595

@@ -703,6 +704,12 @@ Backup and Restoration Roles
703704
modification operations, *only* modify these data using the
704705
:ref:`user management methods <user-management-methods>`.
705706

707+
On the :ref:`cluster <resource-cluster>` as a whole, provides the
708+
following actions:
709+
710+
* :authaction:`bypassWriteBlockMode` (Staring in MongoDB 6.0)
711+
* :authaction:`setUserWriteBlockMode` (Starting in MongoDB 6.0)
712+
706713
.. note:: Aside
707714

708715
Starting in version 4.2, MongoDB removes the

source/reference/command/nav-administration.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,5 @@ Administration Commands
197197
/reference/command/setIndexCommitQuorum
198198
/reference/command/setParameter
199199
/reference/command/setDefaultRWConcern
200+
/reference/command/setUserWriteBlockMode
200201
/reference/command/shutdown
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
=====================
2+
setUserWriteBlockMode
3+
=====================
4+
5+
.. contents:: On this page
6+
:local:
7+
:backlinks: none
8+
:depth: 1
9+
:class: singlecol
10+
11+
Definition
12+
----------
13+
14+
.. dbcommand:: setUserWriteBlockMode
15+
16+
.. versionadded:: 6.0
17+
18+
The ``setUserWriteBlockMode`` command blocks and unblocks writes to
19+
the entire cluster.
20+
21+
During cluster to cluster replication, ``mongosync``, the cluster to cluster
22+
synchronization tool, uses ``setUserWriteBlockMode`` command
23+
to block writes on the destination cluster.
24+
25+
.. note::
26+
27+
Users and applications with the :authaction:`bypassWriteBlockMode` privilege
28+
can bypass the block and continue to perform writes.
29+
30+
Syntax
31+
-------
32+
33+
The ``setUserWriteBlockMode`` command has the following syntax:
34+
35+
.. code-block:: text
36+
37+
db.adminCommand(
38+
{
39+
setUserWriteBlockMode: 1,
40+
global: <boolean>
41+
}
42+
)
43+
44+
The command takes the following fields:
45+
46+
.. list-table::
47+
:header-rows: 1
48+
49+
* - Field
50+
- Type
51+
- Description
52+
53+
* - ``setUserWriteBlockMode``
54+
- integer
55+
- Set this field to ``1``.
56+
57+
* - ``global``
58+
- boolean
59+
- Blocks writes on a cluster when set to ``true``. To enable writes on
60+
a cluster, set ``global: false``.
61+
62+
Required Access
63+
---------------
64+
65+
To execute the ``setUserWriteBlockMode`` command, the user must
66+
have the :authaction:`setUserWriteBlockMode` privilege.
67+
68+
69+
Example
70+
--------
71+
72+
#. Enable user write block mode:
73+
74+
.. code-block:: javascript
75+
76+
db.adminCommand( {
77+
setUserWriteBlockMode: 1,
78+
global: true
79+
} )
80+
81+
#. Add a record to the collection:
82+
83+
.. code-block:: javascript
84+
85+
db.names.insertOne( { name: "George Washington Cable" } )
86+
87+
The server blocks the write because the user write block is enabled.
88+
89+
Example Output:
90+
91+
.. code-block:: text
92+
93+
MongoServerError: User writes blocked
94+
95+
#. Disable user write block mode:
96+
97+
.. code-block:: javascript
98+
99+
db.adminCommand( {
100+
setUserWriteBlockMode: 1,
101+
global: false
102+
} )
103+
104+
#. Add a record to the collection:
105+
106+
.. code-block:: javascript
107+
108+
db.names.insertOne( { name: "George Washington Cable" } )
109+
110+
The :method:`~db.collection.insertOne()` method writes to a collection. The
111+
server allows the write because the user write block is disabled.

source/reference/privilege-actions.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,12 @@ Server Administration Actions
574574
User can perform the :dbcommand:`logApplicationMessage` command. Apply
575575
this action to the ``cluster`` resource.
576576

577+
.. authaction:: bypassWriteBlockMode
578+
579+
User can perform writes even when writes are blocked by the
580+
:dbcommand:`setUserWriteBlockMode` command.
581+
Apply this action to the ``cluster`` resource.
582+
577583
.. authaction:: closeAllDatabases
578584

579585
User can perform the deprecated ``closeAllDatabases`` command. Apply this
@@ -688,6 +694,11 @@ Server Administration Actions
688694
User can perform the :dbcommand:`setParameter` command. Apply this
689695
action to the ``cluster`` resource.
690696

697+
.. authaction:: setUserWriteBlockMode
698+
699+
User can perform the :dbcommand:`setUserWriteBlockMode` command.
700+
Apply this action to the ``cluster`` resource.
701+
691702
.. authaction:: shutdown
692703

693704
User can perform the :dbcommand:`shutdown` command. Apply this action

0 commit comments

Comments
 (0)