<SHAMELESS_PLUG>
My previous article about initial sync progress monitoring got some attention, and as I’m a Technical Services Engineer at MongoDB, I got to provide direct feedback during the design phase of SERVER-47863: Initial Sync Progress Metrics!.
You can be a part of this team and this awesome organization too! Head on over to MongoDB’s careers page to see what’s available, or feel free to ping me on LinkedIn if you have any questions.
</SHAMELESS_PLUG>
The goal of this post is to showcase a change that is coming in MongoDB 5.0 that will significantly improve the feedback loop regarding initial sync progress monitoring. With SERVER-47863 being completed, the results of the db.adminCommand({ replSetGetStatus: 1, initialSync: 1 })
now include additional metrics that can be used to help determine how long (approximately) an initial sync will be running for.
Though this feature is planned to be backported to versions 4.4.3 and 4.2.12, at the time of writing backports had not been completed.
If you want to test this yourself, my setup was as follows:
1) Build the server using the install-mongod
SCons target. My version of the server was mongod-4.9.0-alpha-596-g4437864
as a result.
2) Start up a single node replicaset as follows:
1
|
|
3) Using the mongo
shell, initialize the replica set:
1
|
|
4) Seed the test.data
namespace using the following mgeneratejs
and mongoimport
:
1
|
|
5) Start another mongod
and add it to the replica set
1 2 |
|
The above steps will build the mongod
and start up 2 nodes in a replica set with one in a STARTUP2
(initial sync) state.
By connecting to the secondary node directly and issuing a replSetGetStatus
command we can now review the progress of the copy. Note that this will need to be done while the initial sync is in progress; once the node exits the STARTUP2
state and enters a SECONDARY
state, the initialSyncStatus
details will be unavailable.
For example:
1
|
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
The command output has been truncated to focus in on the new fields added to the initialSyncStatus
document. The new metrics details are as follows: