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

race condition in resmoke timeout self-tests

    • Correctness
    • Fully Compatible
    • ALL
    • Hide

      The resmoke timeout self-tests contain a race condition in how the jstests notify the harness that resmoke has started running.

      See https://github.com/mongodb/mongo/blob/fb7e58022833f93c36e3ac5fb6b9bea2c2698050/jstests/resmoke_selftest/end2end/timeout/fixture/timeout0.js#L4

      var sentinelPath = (_getEnv("TMPDIR") || _getEnv("TMP_DIR") || "/tmp") + "/timeout0.js.sentinel";
      removeFile(sentinelPath);
      writeFile(sentinelPath, "");

      Which is run with resmoke args
      --repeatTests=2 and
      --jobs=2

       

      This is a race condition where they may both removeFile then both writeFile, but the file already exists for the second call. This creates the symptom in the log:
      Error: writeFile() can only write to a file which does not yet exist
      which ultimately leads to the test failure.

      Reproducible locally if you inject a sleep() between removeFile and writeFile.

      Show
      The resmoke timeout self-tests contain a race condition in how the jstests notify the harness that resmoke has started running. See https://github.com/mongodb/mongo/blob/fb7e58022833f93c36e3ac5fb6b9bea2c2698050/jstests/resmoke_selftest/end2end/timeout/fixture/timeout0.js#L4 var sentinelPath = (_getEnv( "TMPDIR" ) || _getEnv( "TMP_DIR" ) || "/tmp" ) + "/timeout0.js.sentinel" ; removeFile(sentinelPath); writeFile(sentinelPath, ""); Which is run with resmoke args --repeatTests=2 and --jobs=2   This is a race condition where they may both removeFile then both writeFile, but the file already exists for the second call. This creates the symptom in the log: Error: writeFile() can only write to a file which does not yet exist which ultimately leads to the test failure. Reproducible locally if you inject a sleep() between removeFile and writeFile.
    • 2025-02-04
    • 0

          Assignee:
          sean.lyons@mongodb.com Sean Lyons
          Reporter:
          sean.lyons@mongodb.com Sean Lyons
          Votes:
          0 Vote for this issue
          Watchers:
          2 Start watching this issue

            Created:
            Updated:
            Resolved: