|
In order to perform writes with the same throughput as the primary, secondary nodes need to apply writes in parallel, just as primaries do. However, secondaries cannot tell from the information in the oplog what parallelizations will cause clients to always see a consistent view of the data. To work around this, the secondaries apply oplog entries in arbitrarily selected batches, using rules that ensure that at the end of a batch, the view over the data is consistent. However, during the batch application, the view may not be consistent, and so readers must be blocked. The ParallelBatchWriterMode lock is used to perform this synchronization.
As you have noticed, when there is heavy write load, readers on secondaries can find themselves stuck waiting for batch boundaries to arrive in order to perform reads. This problem is observed in SERVER-21858. However, on storage engines that support MVCC, there is an alternative outlined in SERVER-20328: with some work, we could allow readers on secondaries to read from the view of the data at the end of the most recently competed batch. I would recommend that you watch and vote on SERVER-20328, if you are interested.
|