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

Balancer may trip invariants due to concurrent usage of opCtx from different threads

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.2.0
    • Affects Version/s: None
    • Component/s: Sharding
    • Labels:
      None
    • Fully Compatible
    • ALL

      Balancer::_moveChunks can submit several asynchonous moveChunk requests concurrently. Each one of these calls to BalancerCommandsSchedulerImpl::requestMoveChunk will use the same opCtx. BalancerCommandsSchedulerImpl::requestMoveChunk will return a SemiFuture, that stores a copy of the opCtx pointer, and as part of its execution will use that opCtx to call processCommandResponse, which will call setLastOpToSystemLastOpTime which takes locks and thus alters the lock state of that opCtx. Thus several threads can concurently alter the opCtx's state, and this can lead to tripping invariants.

      setLastOpToSystemLastOpTime should not be called from the executor callbacks.

            Assignee:
            paolo.polato@mongodb.com Paolo Polato
            Reporter:
            jordi.serra-torrens@mongodb.com Jordi Serra Torrens
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: