All Products
Search
Document Center

ApsaraDB for MongoDB:How to forcibly terminate a request that is being processed in MongoDB

Last Updated:Mar 28, 2026
Important

Before performing operations that may cause risks, such as modifying instance configurations or data, check the disaster recovery and fault tolerance capabilities of your instances to make sure data is secure. Before modifying configurations or data on instances such as Elastic Compute Service (ECS) or Relational Database Service (RDS), create snapshots or enable RDS log backup. If you have shared sensitive information such as logon credentials in the Alibaba Cloud Management Console, update that information promptly.

ApsaraDB for MongoDB lets you forcibly stop a request that is still being processed. Before stopping a request, identify which operation is causing the issue.

Prerequisites

Before you begin, ensure that you have:

  • An ApsaraDB for MongoDB instance (standalone instance, replica set instance, or sharded cluster instance)

  • Access to the mongo shell

For connection instructions, see:

Find the operation to stop

  1. Connect to your ApsaraDB for MongoDB instance through the mongo shell.

  2. Run the following command to list all current operations:

    db.currentOp()

    The output includes the following fields for each operation:

    FieldDescription
    clientThe client that sent the request
    opidThe unique identifier of the operation
    secs_runningHow long the operation has been running, in seconds
    microsecs_runningHow long the operation has been running, in microseconds
    nsThe target collection (namespace) of the operation
    opThe operation type: query, insert, update, or delete
    locksLock information for the operation
  3. Review the output and identify the operation to stop.

    If CPU usage is high and business responses are slow, focus on secs_running and microsecs_running. A large value indicates a long-running operation — check whether the request is legitimate before stopping it.

    Note the opid of the operation you want to stop.

Stop the operation

Run db.killOp() with the opid you identified:

db.killOp(<opid>)

Replace <opid> with the actual operation ID from the db.currentOp() output.

Application scope

  • Metrics for ApsaraDB for MongoDB