TransactionHistoryIterator should read at the lastApplied respecting all visibility rules all the time. There are two problems with the current read timestamp contract.
First, when a timestamp read source is set in a AutoGetCollectionForRead on a recovery unit, it's never reset automatically. A following read can reset it in the following AutoGetCollectionForRead. However, a following write on the same opCtx will use the same timestamp and may hit infinite write conflicts. We cannot change this behavior of AutoGetCollectionForRead since there might be code depending on it implicitly.
Second, if the read timestamp is set in waitForReadConcern, the following TransactionHistoryIterator will affected and it shouldn't be. This prevents us from pushing down session checkout to where we execute the command after wait for read concern.
Thus, we need an RAII type to express the expected read timestamp and restore it afterwards. OneOffRead introduced by daniel.gottlieb is a great prototype. We should productize it and use it in the two above cases.
In the future, it will be great to remove the read timestamp logic from AutoGetCollectionForRead and express the read timestamp explicitly on its own, but that's out of the scope of this ticket.
- is depended on by
-
SERVER-40081 Move session checkout to before command execution
- Closed