Cette page n'est pas encore disponible dans votre langue. Nous nous efforçons d'ajouter d'autres langues. Nous vous remercions de votre compréhension.
- What's New
- Function Overview
- Service Overview
-
Getting Started
- Overview
- Getting Started with Clusters
- Getting Started with Replica Sets
- Getting Started with Single Nodes
- Logging In to the DDS Console
- Example: Buying and Connecting to a DDS Instance
- Change History (Getting Started) Europe Site
-
User Guide
- Migrating Data
- Performance Tuning
- Permissions Management
- Instance Lifecycle Management
- Instance Modifications
- Data Backups
- Data Restorations
-
Parameter Template Management
- Overview
- Creating a Parameter Template
- Modifying a Parameter Template
- Viewing Parameter Change History
- Exporting a Parameter Template
- Comparing Parameter Templates
- Replicating a Parameter Template
- Resetting a Parameter Template
- Applying a Parameter Template
- Viewing Application Records of a Parameter Template
- Modifying the Description of a Parameter Template
- Deleting a Parameter Template
- Connection Management
- Database Usage
- Data Security
- Monitoring and Alarm Reporting
- Auditing
- Logs
- Task Center
- Billing
- Tags
- Quotas
- DDS Usage Suggestions
- Change History
- Developer Guide
-
Best Practices
- Overview
- Common Methods for Connecting to a DDS Instance
- How Do Replica Sets Achieve High Availability and Read/Write Splitting?
- Sharding
- How Do I Improve DDS Performance by Optimizing SQL Statements?
- How Do I Prevent the Mongos Cache Problem?
- How Do I Solve the High CPU Usage Issue?
- Creating a User and Granting the Read-Only Permission to the User
- Security White Paper
- Performance White Paper
-
API Reference
- Before You Start
- API Overview
- Calling APIs
- Getting Started
-
APIs V3.0 (Recommended)
- Querying the API Version
- Querying Database Version Information
- Querying Database Specifications
- Querying the Database Disk Type
-
DB Instance Management
- Creating a DB Instance
- Restarting a DB Instance
- Deleting a DB Instance
- Querying Instances and Details
- Scaling Up Storage Space
- Adding Nodes for a Cluster Instance
- Modifying DB Instance Specifications
- Performing a Primary/Secondary Switchover in a Replica Set Instance
- Enabling or Disabling SSL
- Modifying a DB Instance Name
- Changing an Instance Description
- Changing a Database Port
- Changing a Security Group
- Binding an EIP
- Unbinding an EIP
- Changing a Private IP Address
- Creating Shard or Config IP Addresses of a Cluster Instance
- Configuring Cross-CIDR Access for a Replica Set
- Querying AZs to Which an Instance Can Be Migrated
- Migrating a DB Instance to Another AZ
- Adding Nodes to a Replica Set Instance
- Adding a Read Replica to an Instance
- Connection Management
-
Backup and Restoration
- Creating a Manual Backup
- Deleting a Manual Backup
- Querying the Backup List
- Querying an Automated Backup Policy
- Setting an Automated Backup Policy
- Restoring Data to a New DB Instance
- Obtaining the Link for Downloading a Backup File
- Querying the Restoration Time Ranges
- Obtaining the List of Databases That Can Be Restored
- Obtaining the List of Database Collections That Can Be Restored
- Restoring Data to the Original DB Instance
- Restoring Databases and Tables to a Point in Time
- Parameter Configuration
- Log Information Queries
- Tag Management
-
Managing Databases and Users
- Creating a Database User
- Creating a Database Role
- Querying Details About Database Users
- Querying the Database Role List
- Changing the Password of a Database User
- Checking the Password for Logging In to a Database
- Querying Cluster Balancing Settings
- Enabling or Disabling Cluster Balancing
- Setting the Activity Time Window for Cluster Balancing
- Deleting a Database User
- Deleting a Database Role
- Quota Management
- Task Management
- API V3 (Unavailable Soon)
- Examples
- Permissions Policies and Supported Actions
- Appendix
- Change History (European Sites)
- SDK Reference
-
FAQs
-
Product Consulting
- What Is the Relationship Between DDS and MongoDB Community Edition?
- What Are the Differences Between DDS and GaussDB(for Mongo)?
- What Precautions Should Be Taken When Using DDS?
- What Is the Availability of DDS DB Instances?
- Will My DDS DB Instances Be Affected by Other Users' DDS DB Instances?
- Does DDS Support Multi-AZ Deployment?
- Can I Change the VPC for a Created Instance?
- Can I Change the Region for a Created Instance?
- What Is Hidden Node?
- Database Versions
-
Resource and Disk Management
- Which Items Occupy the Storage Space of DDS Instances?
- Which Types of Logs and Files Occupy DDS DB Instance Storage Space?
- Why Is the Storage Space Usage Displayed on the GUI Smaller Than the Actual Usage?
- Why Does Available Disk Space Not Increase After Data Is Deleted?
- Why Is the Resident Memory of a 4 vCPUs/8 GB Memory Replica Set Instance Only 4 GB?
- Capacity Expansion and Specification Changes
-
Database Performance
- When Will a Primary/Standby Switchover Be Triggered for a Cluster or Replica Set?
- High Storage Usage
- What Is the Time Delay for Primary/Secondary Synchronization in a Replica Set?
- How Is Data Transferred Between the Primary and Secondary Nodes of a Replica Set?
- How Do I Clear an Alarm Saying the Shard Memory Usage Exceeds 90%?
- What Can I Do If a Query Error Is Reported After Data Is Written Into the DDS Cluster?
- Database Permissions
-
Creation and Deletion
- How Do I Select Instance Specifications and Nodes?
- Why Is an Instance Not Displayed on the Console After It Is Created?
- Can I Use a Template to Create DDS DB Instances?
- Why Is Data Missing from My Database?
- Will My Backups Be Deleted If I Delete My Cloud Account?
- What Are the Differences Between Instance Deletion and Unsubscription?
-
Database Connection
- What Should I Do If I Fail to Connect to a DDS Instance?
- What Can I Do If the Number of Connections of an Instance Reaches Its Maximum?
- How Do I Query and Limit the Number of Connections?
- What Should I Do If the ECS and DDS Are Deployed in Different VPCs and They Cannot Communicate with Each Other?
- Do Applications Need to Support Automatic Reconnecting to the DDS Database?
- How Do I Create and Log In to an ECS?
- Installing a Client
- Database Usage
- Database Migration
- Database Storage
- Database Parameters
- Backup and Restoration
- Network Security
- Monitoring and Alarm
- Change History (FAQs) Europe Site
-
Product Consulting
-
Troubleshooting
- DDS Instance Node Fault Handling Mechanism
- Connection Failure Message: network error while attempting to run command 'isMaster'
- Connection Failure Messages: No route to host and connection attempt failed
- Connection Failure Message: Authentication failed
- Connection Failure Message: couldn't connect to server
- Connection Failure Message: cannot list multiple servers in URL without 'replicaSet' option
- Connection Failure Message: Timeout while receiving message
- Connection Failure Message: exception: login failed and U_STRINGPREP_PROHIBITED_ERROR
- Change History (Troubleshooting) European Sites
- Videos
How Do I Prevent the Mongos Cache Problem?
Background
DDS is a document-oriented database service based on distributed file storage, famed for its scalability, high performance, open source, and free mode.

A cluster instance consists of the following three parts:
- Mongos is deployed on a single node. It provides APIs to allow access from external users and shields the internal complexity of the distributed database. A DDS cluster can contain 2 to 12 mongos. You can add them as required.
- Config server is deployed as a replica set. It stores metadata for a sharded cluster. The metadata include information about routes and shards. A cluster contains only one config server.
- Shard server is deployed as a replica set. It stores user data on shards. You can add shard servers in a cluster as required.
Sharding
Sharding is a method for distributing data evenly across multiple shard servers based on a specified shard key. The collection that has a shard key is called sharded collection. If the collection is not sharded, data is stored on only one shard server. DDS cluster mode allows the coexistence of sharded collection and non-sharded collection.
You can run the sh.shardCollection command to convert a non-sharded collection into a sharded collection. Before sharding, ensure that the sharding function is enabled on the database where the collections to be sharded are located. You can run the sh.enableSharding command to enable the sharding function.
Caching Metadata with mongos
User data is stored in the shard server and metadata is stored in the config server. The route information belongs to metadata and is also stored in the config server. When a user needs to access data through mongos, mongos sends the user's requests to the corresponding shard server according to the route information stored on the config server.
This means that every time the user accesses the data, mongos needs to connect to the config server for the route information, which may affect the system performance. Therefore, a cache mechanism is developed for the mongos to cache the route information of the config server. In this scenario, not only the config server stores the route information, but also the mongos caches the route information.
If no operation is performed on mongos, mongos does not cache any route information. In addition, the route information cached on mongos may not be the latest because the information is only updated in the following scenarios:
- If the mongos is started, it will obtain the latest route information from the config server and caches them locally.
- If the mongos processes the data request for the first time, it will obtain the route information from the config server. After that, the information is cached and can be used directly at the time when it is required.
- Updating route information by running commands on mongos.
Only the metadata related to the requested data is updated.
The data to be updated is in the unit of DB.
Scenarios
In the scenario where data is not sharded and multiple mongos exist in a sharded cluster, if data is accessed through different mongos, the cached route information on each mongos may become different. The following shows an example scenario:
- Create database A with sharding disabled through mongos1. After data1 is written, data1 is allocated to shard server1 for storage. Then, mongos2 is used to query data. Both mongos1 and mongos2 have cached the route information of database A.
- If database A is deleted through mongos2, the information about database A in the config server and shard server1 is deleted. As a result, mongos1 cannot identify data1 because database A has been deleted.
- When data2 is written to database A through mongos1, data2 will be stored on shard server1 based on the cached route information but actually database A has been deleted. Then, when data3 is written into database A through mongos2, new information about database A will be generated again on the config server and shard server2 because mongos2 has identified that database A has been deleted.
- In this case, the route information cached in the mongos1 and mongos2 is inconsistent. mongos1 and mongos2 are associated with different shard servers, and data is not shared between them. As a result, data inconsistency occurs.

The client queries data through different mongos:
- mongos1: Data2 can be queried, but data3 cannot be queried.
- mongos2: Data3 can be queried, but data2 cannot be queried.
Workaround Suggestion
MongoDB official suggestions: After deleting databases or collections, run db.adminCommand("flushRouterConfig") on all mongos nodes to update the route information.
Reference link: https://docs.mongodb.com/manual/reference/method/db.dropDatabase/index.html#replica-set-and-sharded-clusters
https://jira.mongodb.org/browse/SERVER-17397
Workaround Suggestion
- For the cluster mode, you are advised to enable the sharding function and then shard the collections in the cluster.
- If the database with sharding disabled is deleted, do not create a database or collection with the same name as the deleted database or collection.
If you need to create a database or collection with the same name as the deleted database or collection, log in to all the mongos nodes to update the route information before creating the database and collection.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.