In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Phenomenon
Errors such as ERROR: Too many connections are frequently reported in log logs.
Analysis.
When we see such an error, we probably know why the number of connections is full, or there is a problem in the code that leads to unreasonable connection closure. I always insist on the transmission of ideas first, supplemented by knowledge. Why, because we are all smart people, thinking about how to do that everyone has their own way, so that everyone can make the fastest progress.
All right, there's a lot of nonsense. Let's get back to the point. Why did I mention the idea above? Because only when you have this way of thinking can you do it! Most of the time we want to do something, but we have no ideas! So learning is thinking, not knowledge at all!
After we know the possible causes, we have to investigate them one by one. The general steps are as follows:
1. Look at the number of connections. The maximum number of connections configured by MySQL is 100. however, the maximum number of connections on the application side is 3040 at most. This problem should not occur, so pass is dropped.
2. The rest is the code, focusing on the sql section, which is placed in the place where the connection is established and released for troubleshooting
Source code:
Pool.getConnection (function (err, connection) {
If (err) throw err
Connection.query (sql, function (err, rows, fields) {
If (err) {
Return cosole.error (err)
}
Cb (rows)
});
/ / release this connection
Connection.release ()
Do you see a problem? Well, I guess, I can't tell ~
In fact, the children's shoes with a little bit of knowledge of the code should be able to see that the release connection statement is in the wrong position.
After modification:
Pool.getConnection (function (err, connection) {
If (err) throw err
Connection.query (sql, function (err, rows, fields) {
/ / release the connection
Connection.release ()
If (err) {
Return cosole.error (err)
}
Cb (rows)
3. Verify after revision, everything is all right, Amitabha Buddha!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.