database connection errors

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
User avatar
rotezecke
Power Poster
Power Poster
Posts: 370
Joined: Fri Apr 18, 2008 9:34 pm
Location: Nimbin, Australia

database connection errors

Post by rotezecke »

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)

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 );
  
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 avatar
Rolf
Dev Team Member
Dev Team Member
Posts: 7749
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: database connection errors

Post by Rolf »

I have similar errors at a few sites, haven't found the cause yet either... :-/ Use all "regular" modules, no custom build ones.
Image
- + - + - + - + - + -
Latest CMSMS tutorial: FormBuilder WatchGuard
- + - + - + - + - + -
Did my post help you solving a problem at your (customers) website and it saved you many hours of work?
Great!! Buy me a cup of coffee in return as a small token of appreciation!
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1058
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: database connection errors

Post by DIGI3 »

Could matching up the access logs to the time of the errors help see if there's a pattern? Perhaps bots are hitting urls with random parameters etc so they're not getting cached pages, resulting in lots of db hits?
Not getting the answer you need? CMSMS support options
User avatar
rotezecke
Power Poster
Power Poster
Posts: 370
Joined: Fri Apr 18, 2008 9:34 pm
Location: Nimbin, Australia

Re: database connection errors

Post by rotezecke »

i have since seen the access logs. while i didn't see a pattern, there's one IP that just went nuts with requests. and many of these had not so random parameters, urlencoded queries like (decoded:)

Code: Select all

/**/AND/**/(SELECT/**/5983/**/FROM(SELECT/**/COUNT(*),CONCAT(0x7170706a71,(SELECT/**/(ELT(5983=5983,1))),0x7171717671,FLOOR(RAND(0)*2))x/**/FROM/**/INFORMATION_SCHEMA.PLUGINS/**/GROUP/**/BY/**/x)a)
Do you have any recommendations how to deal with attacks? i suspect just blocking the IP will probably only help for a day.
At least my plugins didnt cause this.
Post Reply

Return to “Developers Discussion”