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

Fix data race in SBE plan cache key calculation related to IndexCatalogEntry minimum visible snapshot

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 6.2.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Fully Compatible
    • ALL
    • v6.1, v6.0
    • QE 2022-10-31
    • 12

      Each SBE plan cache key incorporates a Timestamp defined as the commit timestamp of the most recently constructed index visible to the reader. This is necessary to deal with some subtle concurrency problems for the SBE plan cache which I won't explain here, but you can see this comment or SERVER-65083 for details.

      The code which calculates the SBE plan cache key Timestamp has a data race detected by TSAN. It traverses all indexes, both ready ones and in-progress index builds, and calls getMinimumVisibleSnapshot() on each IndexCatalogEntry. In the case of lock-free reads, this can race with another thread that is setting the value of the minimum visible snapshot on the same object.

      The data race is possible due to a flaw in the catalog's implementation of lock-free reads. As noted in SERVER-70607, the IndexCatalogEntry should follow copy-on-write semantics for the commit timestamp. Until SERVER-70607 is fixed, we can work around the problem. gregory.noma@mongodb.com suggested a workaround in which the SBE plan cache's timestamp calculation simply never considers in-progress index builds. The task for this ticket is to implement the workaround.

            Assignee:
            david.storch@mongodb.com David Storch
            Reporter:
            david.storch@mongodb.com David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: