Fix possible race in failWithErrorCodeInRuncommand failpoint

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 4.3.4
    • Affects Version/s: None
    • Component/s: Replication
    • None
    • Fully Compatible
    • ALL
    • Repl 2020-02-24
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The way that the failWithErrorCodeInRunCommand failpoint is currently implemented is possibly racey.

      The check against shouldFail only indicates the failpoint was active at that particular instant and it is possible that the failpoint gets turned off immediately after, meaning the following call to 'getData' will fassert.

      We should instead do something along the lines of

      if (MONGO_UNLIKELY(failWithErrorCodeInRunCommand.scopedIf([&](const BSONObj& data){
        return data.hasField(...) ...;
      }.isActive())) {
        // build error reply.
      }
      

            Assignee:
            Jason Chan
            Reporter:
            Jason Chan
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: