lastDocID is chosen by looking for a docId field in the last oplog entry restored on every shard and config server. All of the oplog entries on the shards at this point in the test have a docId field. For this to exist, there must be at least one oplog entry to restore on one shard. If not enough writes happen in general, or specifically on the CSRS (which is not currently guaranteed), then there may not be a lastDocID to retrieve. To ensure there is a lastDocID and clarify the test we should do 3 things:
- Fix the test to say "Backing up CSRS" instead of Backing up shard4"
- Get the lastDocID right after getting the restoreOplogEntries so that the test fails much earlier when it needs to.
- Repeatedly choose a PIT restore time and get the restoreOplogEntries until there is a lastDocID. This should be guaranteed to eventually happen since the noop writer is on.