Fix the race condition in ClusterCursorManager

XMLWordPrintableJSON

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

      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
              Reporter:
              Mohammad Dashti (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: