I believe this is 3.6 required.
makeNoopWriteIfNeeded (in read_concern.cpp) will ensure an oplog document exists on the primary with at least the clusterTime. This guarantees the secondary will eventually apply up to the requested clusterTime.
This method can succeed in two(ish) cases.
- The method successfully sends a appendOplogNote to the primary with the requested cluster time. The caller can wait for this document to come down the pipe with confidence.
- While making requests that are not succeeding, the lastAppliedOpTime continues to advance. If it advances beyond the requested clusterTime, there's no need to make further requests.
- A generalization of the previous point, a request may never need to be made, and the method will immediately return.
The method initializes a return status of OK. Some error cases will immediately return an error code, such as not finding the correct shard, or the number of retries to make the request has been exceeded. Otherwise status is assigned the latest result of the request.
However, when a request fails, leaving status in an error state, the lastAppliedOpTime is refreshed. If this new value exceeds the requested clusterTime, the loop will exit, but the code invariants that the status is ok.