All Products
Search
Document Center

ApsaraDB for MongoDB:What do I do if the instance is locked or data cannot be written to the instance due to exhausted disk space?

更新時間:Mar 05, 2024

If the disk space of an ApsaraDB for MongoDB instance is exhausted, the instance is locked and you cannot write data to or delete data from the instance. This topic describes how to troubleshoot write failure due to exhausted disk space.

Symptoms

  • Your application can read data from an instance but cannot write data to the instance.

  • When an administrator connects to the instance by using the mongo shell for troubleshooting, the administrator attempts to write a piece of data and receives the following error message: not authorized on xxxx to execute command. Example:

    db.customer.insert({"name":"zhangsan"})
    WriteCommandError({
            "operationTime" : Timestamp(1563437183, 1),
            "ok" : 0,
            "errmsg" : "not authorized on db1 to execute command { insert: \"customer\", ordered: true, lsid: { id: UUID(\"8d43461c-5c51-49ef-b9b3-9xxxxxxxxf\") }, $clusterTime: { clusterTime: Timestamp(1563437183, 1), signature: { hash: BinData(0, 0C3FAAE747xxxxxx), keyId: 668293399xxxxxx } }, $db: \"db1\" }",
            "code" : 13,
            "codeName" : "Unauthorized",
            "$clusterTime" : {
                    "clusterTime" : Timestamp(1563437183, 1),
                    "signature" : {
                            "hash" : BinData(0,"DD+q50dPTuIQKTzytT5SiTPYX4Q="),
                            "keyId" : NumberLong("66xxxxxxxx")
                    }
            }
    })
  • The administrator finds that the instance status is Locked in the ApsaraDB for MongoDB console.

    Note

    When the disk space of a sharded cluster instance is exhausted, the instance does not enter the Locked state.

Check whether disk space is exhausted

  1. Log on to the ApsaraDB for MongoDB console.
  2. In the upper-left corner of the page, select the resource group and region to which the instance belongs.
  3. In the left-side navigation pane, click Replica set instances or Sharded cluster instance based on the instance type.
  4. On the page that appears, find the instance that you want to manage and click its ID.
  5. To check whether disk space is exhausted, perform the following operations based on the architecture of the instance.

    Note

    The system collects data related to disk space usage at intervals of five minutes.

    • Standalone or replica set instances

      On the Basic Information page, view the instance status and the disk space usage of the instance. In this example, the instance status is Locked, and the disk space usage of the instance exceeds 100%. This indicates that the disk space is exhausted.

      查看磁盘空间使用率

    • Sharded cluster instances

      1. In the left-side navigation pane, click Monitoring Data.

      2. On the Monitoring Data page, select the shard that you want to monitor.选择Shard节点

        Note

        A node ID that starts with d indicates the ID of a shard node, and a node ID that starts with s indicates the ID of a mongos node.

      3. View disk space usage. In this example, the disk space usage of the shard node exceeds 100%. This indicates that the disk space is exhausted.查看磁盘空间使用率

Solutions

Optimization suggestions

If you run the db.collection.remove command to delete a large amount of data from the instance or have not defragment the disk, you can recycle disk fragments to improve disk usage. For more information, see Defragment a disk to improve disk usage.