Skip to content

Commit f8f05e3

Browse files
DOCSP-24392 Add index constraint command examples to mongosync (#288)
1 parent a9c9394 commit f8f05e3

File tree

1 file changed

+84
-21
lines changed

1 file changed

+84
-21
lines changed

source/reference/disaster-recovery.txt

Lines changed: 84 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,30 @@ the following changes that mimic the sync finalization process of the
6161
size. To set your required maximum size, use the
6262
:dbcommand:`collMod` command.
6363

64+
.. _c2c-dr-write-blocking:
65+
66+
Write blocking
67+
--------------
68+
69+
When write blocking is enabled as part of the :ref:`/start
70+
<c2c-api-start>` command, ``mongosync`` blocks user writes on the
71+
destination cluster during replication. If replication ends
72+
prematurely, you must manually unblock writing on the destination.
73+
74+
After writing is enabled, you can redirect writes from your client
75+
application to the destination cluster.
76+
77+
To enable writes, update :dbcommand:`setUserWriteBlockMode`:
78+
79+
.. code-block:: javascript
80+
81+
db.adminCommand(
82+
{
83+
setUserWriteBlockMode: 1,
84+
global: false
85+
}
86+
)
87+
6488
.. _c2c-dr-unique:
6589

6690
Unique Indexes
@@ -79,6 +103,19 @@ For each non-unique index on the destination cluster that should be
79103
unique, run :dbcommand:`collMod` with ``prepareUnique`` set to
80104
``true``.
81105

106+
.. example::
107+
108+
.. code-block:: javascript
109+
:emphasize-lines: 5
110+
111+
db.runCommand( {
112+
collMod: "<collection_name>",
113+
index: {
114+
keyPattern: <index_spec> || name: <index_name>,
115+
prepareUnique: true
116+
}
117+
} )
118+
82119
After running ``collMod``, the index rejects any new writes that
83120
would introduce duplicate keys.
84121

@@ -90,6 +127,19 @@ There may still be uniqueness conflicts in the index after you run
90127
index, run ``collMod`` with ``unique`` set to ``true`` on each of the
91128
non-unique indexes that you want to set as unique.
92129

130+
.. example::
131+
132+
.. code-block:: javascript
133+
:emphasize-lines: 5
134+
135+
db.runCommand( {
136+
collMod: "<collection_name>",
137+
index: {
138+
keyPattern: <index_spec> || name: <index_name>,
139+
unique: true
140+
}
141+
} )
142+
93143
If the call to ``collMod`` succeeds, there are no uniqueness violations
94144
on that index and the index is converted to an unique index.
95145

@@ -109,6 +159,19 @@ to ``MAX_INT`` for :ref:`TTL indexes
109159
<index-feature-ttl>`. To reset ``expireAfterSeconds``, use the
110160
:dbcommand:`collMod` command to change the expiration value.
111161

162+
.. example::
163+
164+
.. code-block:: javascript
165+
:emphasize-lines: 5
166+
167+
db.runCommand( {
168+
collMod: "<collection_name>",
169+
index: {
170+
keyPattern: <index_spec> || name: <index_name>,
171+
expireAfterSeconds: <number_of_seconds>
172+
}
173+
} )
174+
112175
.. _c2c-dr-hidden:
113176

114177
Hidden Indexes
@@ -117,29 +180,18 @@ During synchronization, :ref:`hidden indexes <index-type-hidden>` are
117180
not hidden on the destination cluster. Use the ``collMod`` command to
118181
hide indexes that should be hidden.
119182

120-
.. _c2c-dr-write-blocking:
121-
122-
Write blocking
123-
--------------
124-
125-
When write blocking is enabled as part of the :ref:`/start
126-
<c2c-api-start>` command, ``mongosync`` blocks user writes on the
127-
destination cluster during replication. If replication ends
128-
prematurely, you must manually unblock writing on the destination.
129-
130-
After writing is enabled, you can redirect writes from your client
131-
application to the destination cluster.
183+
.. example::
132184

133-
To enable writes, update :dbcommand:`setUserWriteBlockMode`:
185+
.. code-block:: javascript
186+
:emphasize-lines: 5
134187

135-
.. code-block:: javascript
136-
137-
db.adminCommand(
138-
{
139-
setUserWriteBlockMode: 1,
140-
global: false
141-
}
142-
)
188+
db.runCommand( {
189+
collMod: "<collection_name>",
190+
index: {
191+
keyPattern: <index_spec> || name: <index_name>,
192+
hidden: true
193+
}
194+
} )
143195

144196
.. _c2c-dr-capped-collections:
145197

@@ -149,3 +201,14 @@ Capped Collections
149201
During synchronization, capped collections are set to the maximum
150202
allowable size. To set your required maximum size, use the ``collMod``
151203
command. For details, see :ref:`resize-capped-collection`.
204+
205+
.. example::
206+
207+
.. code-block:: javascript
208+
:emphasize-lines: 3
209+
210+
db.runCommand( {
211+
collMod: "<collection_name>",
212+
cappedSize: <max_size_in_bytes>,
213+
cappedMax: <max_number_of_documents_in_collection>
214+
} )

0 commit comments

Comments
 (0)