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

Run commit handlers atomic for lock-free reads

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • Catalog and Routing
    • Execution EMEA Team 2023-10-02, Execution EMEA Team 2023-10-16, Execution EMEA Team 2023-10-30, CAR Team 2023-11-13, CAR Team 2023-11-27, CAR Team 2023-12-11, CAR Team 2023-12-25, CAR Team 2024-01-08, CAR Team 2024-01-22, CAR Team 2024-02-05, CAR Team 2024-02-19, CAR Team 2024-03-04, CAR Team 2024-03-18, CAR Team 2024-04-01, CAR Team 2024-04-15

      Commit handlers do not run atomically for lock-free reads which is a common source of bugs. When commit handlers were designed no readers could observe a partial state as locks were held.

      An example of an issue is that adding idents to the drop pending reaper and dropping collections/indexes are currently not atomic operations as they execute in separate onCommit handlers and perform separate writes to the CollectionCatalog.

      This leads to a dependency on the order that these onCommit handlers must execute: first adding the drop pending idents to the reaper and then making the drops visible for readers by publishing uncommitted catalog changes.

      These kinds of dependencies are fragile and are currently implemented with hacky solutions with special ways to register the onCommit handlers so they execute in the required order. We should look into ways to clean this up, some ideas:

      1. Make these two writes atomic by performing them under the same CollectionCatalog write. We would need to figure out how to structure the code, should the CollectionCatalog be treated as a write-through cache or should we add a way to register special callbacks that execute as part of catalog visibility.
      2. Snoop the commitTime as it should have been registered on the RecoveryUnit after 

            Assignee:
            Unassigned Unassigned
            Reporter:
            henrik.edin@mongodb.com Henrik Edin
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: