0

Recently, I found that a insert op make the mongod slow query be happend. And always heppend when the secondary mongod instance syncing data from another node.

The replicate set has three members and I set the client driver write concern "w : 2".

the oplog sync will block insert op? what be happend when insert document to a syncing node?

yangbinnnn
  • 79
  • 1
  • 8

1 Answers1

0

The writeConcern setting w:2 means that the write will be acknowledged when exactly two members of the replica set has acknowledged that the write happened (see https://docs.mongodb.com/v3.2/reference/write-concern/#w-option). In other words, it will wait until the write has replicated (via the oplog) to one other node, since the Primary is counted as one node.

This means that the "speed" of the insert/update query will be subject to your network speed. If the network is slow or congested, then the insert will appear to be "slow". This is not due to replication blocking anything, it is simply the effect of specifying w:2 in a congested network.

There may be a network congestion that triggers both the sync source change and the slow insert, but the replication process by itself does not block any insert operation.

kevinadi
  • 13,365
  • 3
  • 33
  • 49