Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-475

Support termination of database operations on Ctrl+C

    • Type: Icon: Story Story
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 0.13.1
    • Affects Version/s: None
    • Component/s: None
    • None
    • Not Needed

      Ctrl+C should mimic the old shell behaviour and terminate directly, or after confirmation, the database operations that are still pending for the current line being executed.

      Beside providing a more expected UX, this feature also prevents users from exhausting the connection pool on long running operations that should have been supposedly terminated, and would mitigate the issue with asynchronous code being not really interrupted, since most of the async code would be due to database commands. (See attachments).

      Note 1:
      Other previously running operations should not be terminated.

      Note 2:
      On ctrl+c we may need to account for code of this kind, where terminating the current operation in progress would not prevent further operations in the same session to be triggered:

      for (const line of csv) {
         try {
            db.coll1.insertOne(line)
         } catch (e) {
            // ignore
         }
      }
      

      Note 3: See: https://github.com/10gen/compass-internal-docs/blob/master/technical/misc/tracking-background-operations.md for info about how to track and terminate background operations.

        1. ctrl-c-async-code.png
          ctrl-c-async-code.png
          36 kB
        2. ctrlc-connection-pool.png
          ctrlc-connection-pool.png
          65 kB

            Assignee:
            michael.rose@mongodb.com Michael Rose (Inactive)
            Reporter:
            maurizio.casimirri@mongodb.com Maurizio Casimirri
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: