Skip to content

Commit 93d693a

Browse files
author
Dave Cuthbert
authored
DOCSP-23354 disaster recovery v1.0 (#75)
* DOCSP-23354 Disaster recovery * DOCSP-23354 Disaster recovery * Staging fixes * review feedback * Review feedback * Staging fixes * Reveiw feedback
1 parent 4cbcab2 commit 93d693a

File tree

2 files changed

+124
-0
lines changed

2 files changed

+124
-0
lines changed

source/reference.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@ Reference
1212
/reference/api
1313
/reference/mongosync-states
1414
/reference/oplog-sizing
15+
/reference/configuration
16+
/reference/failure-recovery
1517
/reference/limitations
1618

source/reference/failure-recovery.txt

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
.. _c2c-failure-recovery:
2+
3+
==========================
4+
Recovery From Sync Failure
5+
==========================
6+
7+
.. default-domain:: mongodb
8+
9+
.. contents:: On this page
10+
:local:
11+
:backlinks: none
12+
:depth: 2
13+
:class: singlecol
14+
15+
:program:`mongosync` temporarily alters some collection characteristics
16+
during synchronization. The original values are restored during the
17+
:ref:`commit process <c2c-api-commit>`. However, a permanent system
18+
failure could disrupt synchronization before the sync is committed. If
19+
the sync ends prematurely, you must manually reset the collection
20+
characteristics on the destination cluster.
21+
22+
Manually revert the following temporary changes:
23+
24+
- :ref:`Unique indexes set as non-unique <c2c-dr-unique>`
25+
- :ref:`TTL indexes with expireAfterSeconds set to MAX_INT
26+
<c2c-dr-ttl>`
27+
- :ref:`Hidden indexes set as non-hidden <c2c-dr-hidden>`
28+
- :ref:`Capped collections with size/max set to the maximum possible
29+
value <c2c-dr-capped>`
30+
- :ref:`Write blocking <c2c-dr-write-blocking>`
31+
32+
.. _c2c-dr-unique:
33+
34+
Unique Indexes
35+
--------------
36+
37+
:program:`mongosync` replicates writes in parallel, which can cause
38+
transient uniqueness violations on the destination cluster. To avoid
39+
these errors, unique indexes are replicated as non-unique. If
40+
synchronization ends early, manually resolve any uniqueness violations
41+
and convert the non-unique indexes back to unique indexes.
42+
43+
Prepare the Index for Conversion
44+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
45+
46+
For each non-unique index on the destination cluster that should be
47+
unique, run :dbcommand:`collMod` with ``prepareUnique`` set to
48+
``true``.
49+
50+
After running ``collMod``, the index rejects any new writes that
51+
would introduce duplicate keys.
52+
53+
Resolve Uniqueness Violations
54+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
55+
56+
There may still be uniqueness conflicts in the index after you run
57+
``prepareUnique``. To find conflicts and convert the index to a unique
58+
index, run ``collMod`` with ``unique`` set to ``true`` on each of the
59+
non-unique indexes that you want to set as unique.
60+
61+
If the call to ``collMod`` succeeds, there are no uniqueness violations
62+
on that index and the index is converted to an unique index.
63+
64+
If the call to ``collMod`` fails with a ``CannotConvertIndexToUnique``
65+
error, correct the uniqueness violations and rerun ``collMod``.
66+
67+
See: `Convert an Existing Index
68+
<https://www.mongodb.com/docs/v6.0/reference/command/collMod/#convert-an-existing-index-to-a-unique-index>`__
69+
70+
.. _c2c-dr-ttl:
71+
72+
TTL Indexes
73+
-----------
74+
75+
During synchronization, ``expireAfterSeconds`` is set
76+
to ``MAX_INT`` for :ref:`TTL indexes
77+
<index-feature-ttl>`. To reset ``expireAfterSeconds``, use the
78+
``collMod`` command. See: :ref:`Change Expiration Value for Indexes
79+
<ex-change-exp-value>`.
80+
81+
82+
.. _c2c-dr-hidden:
83+
84+
Hidden Indexes
85+
--------------
86+
During synchronization, :ref:`hidden indexes <index-type-hidden>` are
87+
not hidden on the destination cluster. Use the ``collMod`` command to
88+
hide indexes that should be hidden.
89+
90+
.. _c2c-dr-capped:
91+
92+
Capped Collections
93+
------------------
94+
95+
During synchronization, :ref:`capped collections
96+
<manual-capped-collection>` are set to the maximum allowable size. Use
97+
the ``collMod`` command to set the correct maximum size.
98+
99+
.. _c2c-dr-write-blocking:
100+
101+
Write blocking
102+
--------------
103+
104+
When write blocking is enabled as part of the :ref:`/start
105+
<c2c-api-start>` command, ``mongosync`` blocks user writes on the
106+
destination cluster during replication. If replication ends
107+
prematurely, you must manually unblock writing on the destination.
108+
109+
After writing is enabled, you can redirect writes from your client
110+
application to the destination cluster.
111+
112+
To enable writes, update :dbcommand:`setUserWriteBlockMode`:
113+
114+
.. code-block:: javascript
115+
116+
db.adminCommand(
117+
{
118+
setUserWriteBlockMode: 1,
119+
global: false
120+
}
121+
)
122+

0 commit comments

Comments
 (0)