[SERVER-40053] Add an RAII type to change and restore the timestamp read source Created: 08/Mar/19  Updated: 29/Oct/23  Resolved: 20/Mar/19

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: None
Fix Version/s: 4.1.10

Type: Task Priority: Major - P3
Reporter: Siyuan Zhou Assignee: Siyuan Zhou
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-40081 Move session checkout to before comma... Closed
Backwards Compatibility: Fully Compatible
Sprint: Repl 2019-03-25
Participants:

 Description   

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.



 Comments   
Comment by Githook User [ 20/Mar/19 ]

Author:

{'email': 'siyuan.zhou@mongodb.com', 'name': 'Siyuan Zhou', 'username': 'visualzhou'}

Message: SERVER-40053 Add an RAII type to change and restore the timestamp read source
Branch: master
https://github.com/mongodb/mongo/commit/01d8fbb1f0373f0fcca7b2d602f1e593cdc5a379

Generated at Thu Feb 08 04:53:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.