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

Fix the race condition in ClusterCursorManager

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 6.2.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Fully Compatible
    • ALL
    • QE 2022-10-17
    • 129

      It appears that cursorsTimedOut() and incrementCursorsTimedOut can be called on different threads, and there is no lock
      https://github.com/10gen/mongo/blob/7b470a0d23c5a0e86f398082f88e1f136837d320/src/mongo/s/query/cluster_cursor_manager.h#L518-L524

      Here's the writer:
      https://github.com/10agen/mongo/blob/7b470a0d23c5a0e86f398082f88e1f136837d320/src/mongo/s/query/cluster_cursor_cleanup_job.cpp#L65-L66

       

      Here's the reader:
      https://github.com/10gen/mongo/blob/7b470a0d23c5a0e86f398082f88e1f136837d320/src/mongo/s/cluster_cursor_stats.cpp#L48-L49

      In practice, this race is unlikely, but it's worth fixing. Also, it's creating a lot of noise on TSAN builds (e.g., BF-26555). Probably just using a std::atomic for _cursorsTimedOut will solve the issue.

            Assignee:
            romans.kasperovics@mongodb.com Romans Kasperovics
            Reporter:
            mohammad.dashti@mongodb.com Mohammad Dashti (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: