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

shell output from exited programs remains after clearing

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.2.7
    • Component/s: Shell
    • None
    • ALL
    • Hide

      I wrote a simple script to reproduce this:

      var text = "";
      for (var i = 1; i <= 10; i++) {
        text += "Test line #" + i + "\n";
      }
      var startTime = new Date();
      for (i = 1; i < 100000; i++) {
        var exitCode = runMongoProgram("echo", text);
        assert.eq(0, exitCode);
        assert.neq("", rawMongoProgramOutput(), "got an exit code but there's no output");
        clearRawMongoProgramOutput();
        var remainingText = rawMongoProgramOutput();
        if (remainingText !== "") {
          var timeTaken = (new Date() - startTime) / 1000;
          var msg = "still text remaining!\ntook "+i+" tries and "+timeTaken+" seconds\ntext remaining: '"+remainingText+"'";
          assert(false, msg);
        }
      }
      

      Saving that script to a file and running it with the mongo shell eventually fails:

      assert failed : still text remaining!
      took 15648 tries and 38.383 seconds
      text remaining: 'sh51568| Test line #3
      '
      

      I have seen it fail in the same way in as little as one second. It has also failed occasionally on the line which asserts that the echo produces some output after it has exited.

      Show
      I wrote a simple script to reproduce this: var text = ""; for (var i = 1; i <= 10; i++) { text += "Test line #" + i + "\n"; } var startTime = new Date(); for (i = 1; i < 100000; i++) { var exitCode = runMongoProgram("echo", text); assert.eq(0, exitCode); assert.neq("", rawMongoProgramOutput(), "got an exit code but there's no output"); clearRawMongoProgramOutput(); var remainingText = rawMongoProgramOutput(); if (remainingText !== "") { var timeTaken = (new Date() - startTime) / 1000; var msg = "still text remaining!\ntook "+i+" tries and "+timeTaken+" seconds\ntext remaining: '"+remainingText+"'"; assert(false, msg); } } Saving that script to a file and running it with the mongo shell eventually fails: assert failed : still text remaining! took 15648 tries and 38.383 seconds text remaining: 'sh51568| Test line #3 ' I have seen it fail in the same way in as little as one second. It has also failed occasionally on the line which asserts that the echo produces some output after it has exited.
    • Platforms 18 (08/05/16)

      The output of a program after a program exits does not always clear out after calling clearRawMongoProgramOutput.

      This issue causes some jstests in mongo-tools to fail intermittently. They are being rewritten to work around this issue.

            Assignee:
            matt.cotter Matt Cotter
            Reporter:
            zach.snow Zach Snow
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: