|
| 1 | +.. _terminate-running-query: |
| 2 | + |
| 3 | +============================================= |
| 4 | +Terminate a Running {+data-lake-short+} Query |
| 5 | +============================================= |
| 6 | + |
| 7 | +.. default-domain:: mongodb |
| 8 | + |
| 9 | +.. contents:: On this page |
| 10 | + :local: |
| 11 | + :backlinks: none |
| 12 | + :depth: 2 |
| 13 | + :class: singlecol |
| 14 | + |
| 15 | +You can terminate long-running queries using the :manual:`killOp |
| 16 | +</reference/command/killOp/>` command. For more information, see |
| 17 | +:manual:`killOp </reference/command/killOp/>`. In {+adl+}: |
| 18 | + |
| 19 | +- The ``op`` parameter value is an :manual:`ObjectId |
| 20 | + </reference/bson-types/#objectid>`. |
| 21 | +- The ``comment`` parameter is not supported. |
| 22 | + |
| 23 | +Only the user who issued the query can terminate the query. To run |
| 24 | +this command, use :manual:`db.runCommand() |
| 25 | +</reference/method/db.runCommand>`. You must run :manual:`killOp |
| 26 | +</reference/command/killOp/>` against the ``admin`` database. |
| 27 | + |
| 28 | +.. _adl-killop-syntax: |
| 29 | + |
| 30 | +Syntax |
| 31 | +------ |
| 32 | + |
| 33 | +.. code-block:: json |
| 34 | + |
| 35 | + db.runCommand([{ "killOp": 1, "op": ObjectId(<hexadecimal>) }]) |
| 36 | + |
| 37 | +.. _adl-killop-options: |
| 38 | + |
| 39 | +Options |
| 40 | +------- |
| 41 | + |
| 42 | +.. list-table:: |
| 43 | + :header-rows: 1 |
| 44 | + :widths: 15 15 60 10 |
| 45 | + |
| 46 | + * - Field |
| 47 | + - Type |
| 48 | + - Description |
| 49 | + - Necessity |
| 50 | + |
| 51 | + * - ``op`` |
| 52 | + - :manual:`ObjectId </reference/bson-types/#objectid>` |
| 53 | + - Unique identifier, in :manual:`ObjectId |
| 54 | + </reference/bson-types/#objectid>` format, of the operation |
| 55 | + to terminate. You can use :ref:`$currentOp |
| 56 | + <determine-query-status>` to retrieve the ``opid`` of the |
| 57 | + operation to terminate. |
| 58 | + - Required |
| 59 | + |
| 60 | +.. _adl-killop-output: |
| 61 | + |
| 62 | +Output |
| 63 | +------ |
| 64 | + |
| 65 | +:manual:`killOp </reference/command/killOp/>` returns the following |
| 66 | +if it succeeds in marking the specified operation for termination: |
| 67 | + |
| 68 | +.. code-block:: |
| 69 | + :copyable: false |
| 70 | + |
| 71 | + { "info" : "attempting to kill op", "ok" : 1 } |
| 72 | + |
| 73 | +Note that the output is the same whether or not the operation being |
| 74 | +terminated is currently running. You can use :ref:`$currentOp |
| 75 | +<determine-query-status>` to verify that the operation was terminated. |
| 76 | + |
| 77 | +.. _adl-killop-egs: |
| 78 | + |
| 79 | +Examples |
| 80 | +-------- |
| 81 | + |
| 82 | +For the example below, suppose a query with ``opid`` value of |
| 83 | +``ObjectId("1635fad364c529820c6f9e76")`` is running. The following |
| 84 | +command terminates this query. |
| 85 | + |
| 86 | +.. code-block:: json |
| 87 | + |
| 88 | + use admin |
| 89 | + db.runCommand({ "killOp": 1, "op": ObjectId("1635fad364c529820c6f9e76") }) |
| 90 | + |
| 91 | +The previous command returns the following: |
| 92 | + |
| 93 | +.. code-block:: json |
| 94 | + :copyable: false |
| 95 | + |
| 96 | + { "info" : "attempting to kill op", "ok" : 1 } |
0 commit comments