Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-40053

Add an RAII type to change and restore the timestamp read source

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.1.10
    • Affects Version/s: None
    • Component/s: Storage
    • Labels:
      None
    • Fully Compatible
    • Repl 2019-03-25

      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.

            Assignee:
            siyuan.zhou@mongodb.com Siyuan Zhou
            Reporter:
            siyuan.zhou@mongodb.com Siyuan Zhou
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: