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

Fix incorrect uses of assert.soon and make hang-analysis call exit

    • Type: Icon: New Feature New Feature
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.3.1
    • Affects Version/s: Backlog
    • Component/s: Internal Code
    • Labels:
      None
    • Fully Compatible
    • STM 2019-10-31
    • 3

      A number of places use assert.soon as a retry mechanism (e.g. ssl_test.js), and at least one test (index_delete.js) runs assert.soon in a try/finally block to capture better error messages.

      ↑ looks like this:

          try {
              assert.soon(function() {
                  return checkProgram(serverPID).alive &&
                      (0 === _runMongoProgram.apply(null, clientArgv));
              }, "connect failed", connectTimeoutMillis);
          } catch (ex) {
              return false;
          } finally {
              _stopMongoProgram(this.port);
          }
      

      In the cases where assert.soon fails due to timeout, we want to instead run hang-analysis and exit rather than returning control to the caller.

      (Comment from Robert: I think assert.soon almost always fails due to a timeout. What's the reason for exiting in this case?)

      Uses of assert.soon are pervasive in jstests so do a best-effort fix here. Could modify assert.soon in a patch-build to throw immediately and any test that doesn't fail is likely using it incorrectly.

      If there are more than (say) 3-4 cases of using assert.soon as a retry mechanism, create a helper assert.retry method (name/location tbd) that has a similar signature to assert.soon but doesn't call hang-analyzer or barf if the callback is never truthy and instead returns a [success, error] array where success is the last result of the callback and error is any errors thrown by the callback. (Exact signature tbd depending on how it's used by callers of extant assert.soon.)

      Finally, once this is done, modify existing callers of the hang-analyzer (probably just assert.soon) to call exit after running hang-analysis.

            Assignee:
            robert.guo@mongodb.com Robert Guo (Inactive)
            Reporter:
            ryan.timmons@mongodb.com Ryan Timmons
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: