@@ -25,7 +25,13 @@ Initial Sync
25
25
------------
26
26
27
27
Initial sync copies all the data from one member of the replica set to
28
- another member.
28
+ another member. See :ref:`replica-set-initial-sync-source-selection` for
29
+ more information on initial sync source selection criteria.
30
+
31
+ Starting in MongoDB 4.4, you can specify the preferred initial sync
32
+ source using the :parameter:`initialSyncSourceReadPreference` parameter.
33
+ This parameter can only be specified when starting the
34
+ :binary:`~bin.mongod`.
29
35
30
36
Process
31
37
~~~~~~~
@@ -87,6 +93,107 @@ synchronization process from the beginning.
87
93
The secondary attempts to restart the initial sync up to ``10`` times
88
94
before returning a fatal error.
89
95
96
+ .. _replica-set-initial-sync-source-selection:
97
+
98
+ Initial Sync Source Selection
99
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
100
+
101
+ Initial sync source selection depends on the value of the
102
+ :binary:`~bin.mongod` startup parameter
103
+ :parameter:`initialSyncSourceReadPreference` (*new in 4.4*):
104
+
105
+ - For :parameter:`initialSyncSourceReadPreference` set to
106
+ :readmode:`primary` (default if :rsconf:`chaining
107
+ <settings.chainingAllowed>` is disabled), select the :term:`primary`
108
+ as the sync source. If the primary is unavailable or unreachable, log
109
+ an error and periodically check for primary availability.
110
+
111
+ - For :parameter:`initialSyncSourceReadPreference` set to
112
+ :readmode:`primaryPreferred` (default for voting replica set
113
+ members), attempt to select the :term:`primary` as the sync source. If
114
+ the primary is unavailable or unreachable, perform sync source
115
+ selection from the remaining replica set members.
116
+
117
+ - For all other supported read modes, perform sync source selection
118
+ from the replica set members.
119
+
120
+ Members performing initial sync source selection make two passes through
121
+ the list of all replica set members:
122
+
123
+ .. tabs::
124
+
125
+ .. tab:: Sync Source Selection (First Pass)
126
+ :tabid: firstpass
127
+
128
+ The member applies the following criteria to each replica
129
+ set member when making the first pass for selecting a
130
+ initial sync source:
131
+
132
+ - The sync source *must* be in the :replstate:`PRIMARY` or
133
+ :replstate:`SECONDARY` replication state.
134
+
135
+ - The sync source *must* be online and reachable.
136
+
137
+ - If :parameter:`initialSyncSourceReadPreference` is
138
+ :readmode:`secondary` or :readmode:`secondaryPreferred`,
139
+ the sync source *must* be a :term:`secondary`.
140
+
141
+ - The sync source *must* be :rsconf:`visible <members[n].hidden>`.
142
+
143
+ - The sync source *must* be within ``30`` seconds of the newest
144
+ oplog entry on the primary.
145
+
146
+ - If the member :rsconf:`builds indexes
147
+ <members[n].buildIndexes>`, the sync source *must*
148
+ build indexes.
149
+
150
+ - If the member :rsconf:`votes <members[n].votes>` in
151
+ replica set elections, the sync source *must* also vote.
152
+
153
+ - If the member is *not* a :rsconf:`delayed member
154
+ <members[n].slaveDelay>`, the sync source *must not* be delayed.
155
+
156
+ - If the member *is* a :rsconf:`delayed member
157
+ <members[n].slaveDelay>`, the sync source must have a shorter
158
+ configured delay.
159
+
160
+ - The sync source *must* be faster (i.e. lower latency) than
161
+ the current best sync source.
162
+
163
+ If no candidate sync sources remain after the first pass,
164
+ the member performs a second pass with relaxed criteria.
165
+ See :guilabel:`Sync Source Selection (Second Pass)`.
166
+
167
+ .. tab:: Sync Source Selection (Second Pass)
168
+ :tabid: second pass
169
+
170
+ The member applies the following criteria to each replica
171
+ set member when making the second pass for selecting a
172
+ initial sync source:
173
+
174
+ - The sync source *must* be in the
175
+ :replstate:`PRIMARY` or :replstate:`SECONDARY` replication
176
+ state.
177
+
178
+ - The sync source *must* be online and reachable.
179
+
180
+ - If :parameter:`initialSyncSourceReadPreference` is
181
+ :readmode:`secondary`, the sync source *must* be a
182
+ :term:`secondary`.
183
+
184
+ - If the member :rsconf:`builds indexes
185
+ <members[n].buildIndexes>`, the sync source must
186
+ build indexes.
187
+
188
+ - The sync source *must* be faster (i.e. lower latency) than
189
+ the current best sync source.
190
+
191
+ If the member cannot select an initial sync source after two passes, it
192
+ logs an error and waits ``1`` second before restarting the selection
193
+ process. The secondary :binary:`~bin.mongod` can restart the initial
194
+ sync source selection process up to ``10`` times before exiting with an
195
+ error.
196
+
90
197
.. _replica-set-replication:
91
198
92
199
Replication
@@ -99,21 +206,8 @@ process. [#slow-oplogs]_
99
206
100
207
Secondaries may automatically change their *sync from* source as needed
101
208
based on changes in the ping time and state of other members'
102
- replication.
103
-
104
- .. versionchanged:: 3.2
105
-
106
- .. include:: /includes/fact-voting-node-sync-incompatibility.rst
107
-
108
- Secondaries avoid syncing from
109
- :ref:`delayed members <replica-set-delayed-members>` and :ref:`hidden
110
- members <replica-set-hidden-members>`.
111
-
112
- If a secondary member has :rsconf:`members[n].buildIndexes` set to ``true``,
113
- it can only sync from other members where :rsconf:`~members[n].buildIndexes`
114
- is ``true``. Members where :rsconf:`~members[n].buildIndexes` is ``false`` can
115
- sync from any other member, barring other sync restrictions.
116
- :rsconf:`~members[n].buildIndexes` is ``true`` by default.
209
+ replication. See :ref:`replica-set-replication-sync-source-selection`
210
+ for more information on sync source selection criteria.
117
211
118
212
.. [#slow-oplogs]
119
213
@@ -151,3 +245,100 @@ Flow Control
151
245
.. include:: /includes/extracts/4.2-changes-flow-control-general-desc.rst
152
246
153
247
For more information, see :ref:`flow-control`.
248
+
249
+ .. _replica-set-replication-sync-source-selection:
250
+
251
+ Replication Sync Source Selection
252
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
253
+
254
+ Replication sync source selection depends on the replica set
255
+ :rsconf:`chaining <settings.chainingAllowed>` setting:
256
+
257
+ - With chaining enabled (default), perform sync source selection from
258
+ the replica set members.
259
+
260
+ - With chaining disabled, select the :term:`primary` as the sync
261
+ source. If the primary is unavailable or unreachable, log an
262
+ error and periodically check for primary availability.
263
+
264
+ Members performing replication sync source selection make two passes
265
+ through the list of all replica set members:
266
+
267
+ .. tabs::
268
+
269
+ .. tab:: Sync Source Selection (First Pass)
270
+ :tabid: firstpass
271
+
272
+ The member applies the following criteria to each replica
273
+ set member when making the first pass for selecting a
274
+ replication sync source:
275
+
276
+ - The sync source *must* be in the :replstate:`PRIMARY` or
277
+ :replstate:`SECONDARY` replication state.
278
+
279
+ - The sync source *must* be online and reachable.
280
+
281
+ - The sync source *must* have newer oplog entries than the member
282
+ (i.e. the sync source is *ahead* of the member).
283
+
284
+ - The sync source *must* be :rsconf:`visible <members[n].hidden>`.
285
+
286
+ - The sync source *must* be within ``30`` seconds of the newest
287
+ oplog entry on the primary.
288
+
289
+ - If the member :rsconf:`builds indexes
290
+ <members[n].buildIndexes>`, the sync source *must*
291
+ build indexes.
292
+
293
+ - If the member :rsconf:`votes <members[n].votes>` in
294
+ replica set elections, the sync source *must* also vote.
295
+
296
+ - If the member is *not* a :rsconf:`delayed member
297
+ <members[n].slaveDelay>`, the sync source *must not* be delayed.
298
+
299
+ - If the member *is* a :rsconf:`delayed member
300
+ <members[n].slaveDelay>`, the sync source must have a shorter
301
+ configured delay.
302
+
303
+ - The sync source *must* be faster (i.e. lower latency) than
304
+ the current best sync source.
305
+
306
+ If no candidate sync sources remain after the first pass,
307
+ the member performs a second pass with relaxed criteria.
308
+ See the :guilabel:`Sync Source Selection (Second Pass)`.
309
+
310
+ .. tab:: Sync Source Selection (Second Pass)
311
+ :tabid: second pass
312
+
313
+ The member applies the following criteria to each replica
314
+ set member when making the second pass for selecting a
315
+ replication sync source:
316
+
317
+ - The sync source *must* be in the
318
+ :replstate:`PRIMARY` or :replstate:`SECONDARY` replication
319
+ state.
320
+
321
+ - The sync source *must* be online and reachable.
322
+
323
+ - If the member :rsconf:`builds indexes
324
+ <members[n].buildIndexes>`, the sync source must
325
+ build indexes.
326
+
327
+ - The sync source *must* be faster (i.e. lower latency) than
328
+ the current best sync source.
329
+
330
+ If the member cannot select a sync source after two passes, it logs an
331
+ error and waits ``1`` second before restarting the selection process.
332
+
333
+ .. note::
334
+
335
+ Starting in MongoDB 4.4, the startup parameter
336
+ :parameter:`initialSyncSourceReadPreference` takes precedence over
337
+ the replica set's :rsconf:`settings.chainingAllowed` setting when
338
+ selecting an initial sync source. After a replica set member
339
+ successfully performs initial sync, it defers to the value of
340
+ :rsconf:`~settings.chainingAllowed` when selecting a replication sync
341
+ source.
342
+
343
+ See :ref:`replica-set-initial-sync-source-selection` for more
344
+ information on initial sync source selection.
0 commit comments