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

ExportedServerParameter<T> is not thread-safe for parameters changeable at runtime.

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.1.9
    • Affects Version/s: None
    • Component/s: Internal Code
    • Labels:
      None
    • Fully Compatible
    • ALL
    • Platform 9 (09/18/15), Platform A (10/09/15)

      ExportedServerParameter does not protect the underlying templated variable from concurrent access.

      The following construct is hence not safe if maxConsecutiveFailedChecks is ever read without holding a lock preventing a setParameter call:

      ExportedServerParameter<int> MaxConsecutiveFailedChecksSetting(                                             
           ServerParameterSet::getGlobal(),                                                                        
           "replMonitorMaxFailedChecks",
           &ReplicaSetMonitor::maxConsecutiveFailedChecks,                                                         
           false,  // allowedToChangeAtStartup                                                                     
           true);  // allowedToChangeAtRuntime
      

      We could either:
      1) Prevent ExportedServerParameter to be configured with allowedToChangeAtRuntime = true, and make implementers having to inherit from ServerParameter directly, or

      2) Use a mutex in ExportedServerParameter or use atomics for the template specializations where that make sense.

      Regardless we should audit the existing uses of ExportedServerParameter.

            Assignee:
            mark.benvenuto@mongodb.com Mark Benvenuto
            Reporter:
            andreas.nilsson Andreas Nilsson
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: