Stop using replSetConfig.unsafePeek and/or make usages safer

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Replication
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      After SERVER-90588, previous usages of replSetConfig.getConfig(WithLock) have been changed to replSetConfig.unsafePeek(). While this usage explicitly says that it is unsafe, it does not require the caller to be holding the replication coordinator mutex. Additionally, replSetConfig.update() also does not require the caller to be holding the replication coordinator mutex. (Internally, update takes a separate internal mutex within VersioendValue, while unsafePeek does not take that mutex.) Currently, from an initial audit I believe all usages of unsafePeek and update are done while taking the replication coordinator mutex, but this still seems very prone to error.

      We should try to make this safer, maybe by adding WithLock as an argument to unsafePeek and update (not sure if possible since the config is using the VersionedValue class which is used elsewhere)
      We could also look into changing all usages of unsafePeek to this function which is safe (uses functions within VersionedValue that take VersionedValue's internal _mutex) but possibly has a performance impact. It seems like switching to this function would be preferred unless there's a strong reason to keep using unsafePeek.

            Assignee:
            Unassigned
            Reporter:
            Huayu Ouyang
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: