Problem description

When the number of connections to an apsaradb for MongoDB instance reaches the upper limit, new connection requests cannot be responded. The following scenarios describe the failures:

Instructions the maximum number of connections varies depending on apsaradb for MongoDB instance types. For more information, see instance specifications.

  • The application fails to connect to the database.
  • The whitelist has been properly set. However, the following error message is displayed when you use the Mongo Shell to connect to the database.
    2019-07-10T10:30:43.597+0800 E QUERY [js] Error: network error while attempting to run command 'isMaster' on host 'dds-bpxxxxxxxx.mongodb.rds.aliyuncs.com:3717' : connect@src/mongo/shell/mongo.js:328:13 @(connect):1:6 exception: connect failed
  • The whitelist has been properly set. However, the following error message is displayed when you use DMS to connect to the database.
    The connection between DMS and the apsaradb for MongoDB server cannot be established. Check whether the connection address is correct, whether the network is running properly, and whether the whitelist is configured properly.

Cause

The error message returned because the number of connections to the apsaradb for MongoDB instance is not reached.

Solution

Alibaba Cloud reminds you that:

  • Before you perform operations that may cause risks, such as modifying instance configurations or data, we recommend that you check the disaster recovery and fault tolerance capabilities of the instances to ensure data security.
  • You can modify the configurations and data of instances including but not limited to Elastic Compute Service (ECS) and Relational Database Service (RDS) instances. Before the modification, we recommend that you create snapshots or enable RDS log backup.
  • If you have authorized or submitted sensitive information such as the logon account and password in the Alibaba Cloud Management Console, we recommend that you modify such information in a timely manner.

Check whether the number of MongoDB connections has been exhausted.

  1. Login apsaradb for MongoDB console.
  2. In the upper-left corner of the page, select the resource group and region where the instance is located.
  3. In the left-side navigation pane, choose sharded cluster instances.
  4. Find the original RDS instance and click its ID.
  5. In the left-side navigation pane, choose monitoring information.
  6. In monitoring information page, view the current connections information. Make sure that the instance has too many connections.
    Instructions to obtain the required monitoring information faster, we recommend that you set the monitoring granularity of the MongoDB instance to seconds. For more information, see set the monitoring granularity.
  7. In the left-side navigation pane, choose basic information.
  8. In basic information page, find connection information area, click view more connections, you can determine whether the number of connections to the instance has reached the limit based on the number of connections established in step 6.

Release connections

You can restart an instance to temporarily release all connections. For more information, see instance restart. To prevent this problem from occurring again, we recommend that you use the following methods after restarting the instance:
Instructions if you restart the instance, all nodes of the instance are restarted one by one. Each node has a transient disconnection of about 30 seconds. If the instance has a large number of collections (more than 10,000), the transient disconnections last longer. Before restarting the instance, arrange your business and ensure that your application has a reconnection mechanism.

Application scope

  • ApsaraDB for MongoDB