Waste a lot of time to store data, all migrated to MongoDB, not a large number of changes is the main cause.
But there was a strange phenomenon.
Soon after the program ran, MongoDB is suspended animation, and another client to login to MongoDB is not.
Restarting the MONGODB server is not getting better.
The reason for this analysis is that MongoDB's connection pool is full and not released.
But from the official website to understand the MongoDB connection is self-management, after the use of automatic release, write a few demo test, also fully meet this point.
Wasted a lot of time looking for the cause of the problem and trying to optimize it.
For example, set the number of TCP connections for Windows, and so on.
Set the number of MONGODB connections, wait time, and so on.
But it's not going to work out.
Finally, I thought, MongoDB connection is self-managed, has its own connection pool, but mongdb with the program I developed before, there is a third party that encapsulates the MongoDB driver.
Think about what is going on inside the driver, so that the connection is maintained for a long time and cannot be returned?
With a try mentality, rewrite all the project code, try{}catch{} in the catch manually close to release the connection.
As a result, the problem no longer occurs.
The reason is clear, because of the anomaly.
MongoDB Connection Smooth completion of the task, automatic release, but with the driver, if out of the ordinary, do not actively switch off the connection, even after the program runs for a period of time, the connection pool is overdrawn.
Develop MongoDB connection Be sure to close the connection, the exception must also be off