database connection errors
Posted: Thu May 14, 2020 4:50 am
If have a problematic site with frequent errors in CMSMS error log:
user xxx has exceeded the max_user_connections ...
I spoke to host, and they by now successfully updated it. so there's no immediate drama. However, the errors were logged on random times, mostly over night. Initially, I did not pay much more attention as it did not affect any real users, probably just bots.
Now, it happens more regularly, also during daytime hours, and I wonder if my poor programming has anything to do with it. I have numerous custom plugins connecting to another database to query this and that. the connection looks like this (courtesy of calguy1000) i don't think i close those connections usually. $db->Close() i guess it is. but could the fact that i don't close the connection contribute to the above problem? but why would overnight where there's next to no traffic (except for bots maybe) be more problematic?
user xxx has exceeded the max_user_connections ...
I spoke to host, and they by now successfully updated it. so there's no immediate drama. However, the errors were logged on random times, mostly over night. Initially, I did not pay much more attention as it did not affect any real users, probably just bots.
Now, it happens more regularly, also during daytime hours, and I wonder if my poor programming has anything to do with it. I have numerous custom plugins connecting to another database to query this and that. the connection looks like this (courtesy of calguy1000)
Code: Select all
//CMSMS 2.2+
$cs = new \CMSMS\Database\ConnectionSpec;
$cs->type = 'mysqli';
$cs->host = $db_host;
$cs->dbname = $db_db;
$cs->username = $db_user;
$cs->password = $db_pw;
$db = \CMSMS\Database\Connection::initialize( $cs );