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

Lock-free reads can read from sharded collection as unsharded when collection is dropped and recreated (ABA problem)

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Storage Execution
    • ALL
    • Execution Team 2023-05-15, Execution Team 2023-05-29, Execution NAMR Team 2023-06-26

      This is hypothetical, we haven't tried to reproduce it.

      The scenario looks like this:

      1. Collection exists and is unsharded.
      2. Mongos attaches shard version UNSHARDED to the request.
      3. Collection becomes sharded from some other client running shardCollection.
      4. AutoGetCollectionLockFree opens the snapshot at this point.
      5. Collection is dropped from some other client running drop.
      6. Collection is created again as unsharded from some other client running create.
      7. AutoGetCollectionForReadCommandLockFree checks and sees the collection is unsharded. Then AutoGetCollectionForReadCommandBase checks the shard version and everything checks out. In particular, CollectionShardingState::checkShardVersionOrThrow() passes because the request was sent with shard version UNSHARDED and the collection is (again now) unsharded.

      Currently we have a check to prevent this exact scenario described in SERVER-62457 , however it relies on the check in AutoGetCollectionForReadCommandLockFree to observe the collection as sharded, if the check happens when the collection is unsharded again the problem is not detected (presumably).

            Assignee:
            henrik.edin@mongodb.com Henrik Edin
            Reporter:
            daniel.gomezferro@mongodb.com Daniel Gomez Ferro
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: