Raised This Month: $32 Target: $400
 8% 

fail to connect to db due to more than 'max_user_connections' active connections


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 10-01-2021 , 02:32   fail to connect to db due to more than 'max_user_connections' active connections
Reply With Quote #1

my host recently upgraded mysql server to version 8 but the max_user_connections was changed from 300 to 100 now i get alot of error like below

Connecting to database failed: [1203]: User xxx already has more than 'max_user_connections' active connections

i was wondering is 100 to low? what do you have your max_user_connections set at?
and how to determine how many connections i would need?
is it for every plugin that connects to the database count as one connection?
or is it for every entry in the addons/sourcemod/config/databases.cfg count as one connection?

thanks
__________________
8guawong is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-01-2021 , 05:45   Re: fail to connect to db due to more than 'max_user_connections' active connections
Reply With Quote #2

Every time when plugin make sql connection, is like one "client".
If one of plugins create lot of connections without deleting old one, it increase "client" amount.
Hang connections open.
*edit When plugin is unloaded, those open connections also disconnect.

Mostly in here forum, SM plugins have script to open sql connection and keep it open all the time, maybe because plugins have made to update records in realtime/fast phase.
In my opinion it is not good practise.

Can you see in your mysql server, how many connection currently is active (or sleep) ?
Can't remember which page it was...
something like "mysql client connections processlist"

__________________
Do not Private Message @me

Last edited by Bacardi; 10-01-2021 at 05:46.
Bacardi is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 10-01-2021 , 09:17   Re: fail to connect to db due to more than 'max_user_connections' active connections
Reply With Quote #3

Quote:
Originally Posted by Bacardi View Post
Every time when plugin make sql connection, is like one "client".
If one of plugins create lot of connections without deleting old one, it increase "client" amount.
Hang connections open.
*edit When plugin is unloaded, those open connections also disconnect.

Mostly in here forum, SM plugins have script to open sql connection and keep it open all the time, maybe because plugins have made to update records in realtime/fast phase.
In my opinion it is not good practise.

Can you see in your mysql server, how many connection currently is active (or sleep) ?
Can't remember which page it was...
something like "mysql client connections processlist"

thx Bacardi
so whenever a plugin does a
https://sm.alliedmods.net/new-api/dbi/Database/Connect
https://sm.alliedmods.net/new-api/dbi/SQL_Connect
https://sm.alliedmods.net/new-api/dbi/SQL_TConnect
it'll count as one connection?

here is what i get with 13 servers running
Code:
MySQL [(none)]> show status where variable_name = 'Threads_connected';
+-------------------+-------+
| Variable_name     | Value |
+-------------------+-------+
| Threads_connected | 101   |
+-------------------+-------+
1 row in set (0.002 sec)
__________________
8guawong is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-01-2021 , 12:14   Re: fail to connect to db due to more than 'max_user_connections' active connections
Reply With Quote #4

what the hell, why sourcebans do that ?
Could it be Web page ? People looking your web page ?

*edit
Show your plugins list also.

Last edited by Bacardi; 10-01-2021 at 12:17.
Bacardi is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 10-01-2021 , 12:57   Re: fail to connect to db due to more than 'max_user_connections' active connections
Reply With Quote #5

Quote:
Originally Posted by Bacardi View Post
what the hell, why sourcebans do that ?
Could it be Web page ? People looking your web page ?

*edit
Show your plugins list also.
well i have sourcebanpp installed
https://sbpp.dev/

so like you said if each plugin connect to database it'll count as one connection
and i have sbpp_checker.smx, sbpp_comms.smx, sbpp_main.smx, sbpp_sleuth.smx
installed and each of them make a connection to the database

https://github.com/sbpp/sourcebans-p...checker.sp#L61
https://github.com/sbpp/sourcebans-p...comms.sp#L2059
https://github.com/sbpp/sourcebans-p...p_main.sp#L214
https://github.com/sbpp/sourcebans-p..._sleuth.sp#L89

out of those 13 servers not all have sourceban installed but yea it adds up!

i blanked out the host from the pic and the host is the server so no its not people looking at web page
__________________

Last edited by 8guawong; 10-01-2021 at 12:58.
8guawong is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-01-2021 , 13:18   Re: fail to connect to db due to more than 'max_user_connections' active connections
Reply With Quote #6

Easy option would be increase your mysql server max_user_connections.

Or you would encounter this same problem later with different plugins.

...rewrite plugins with less connections ? It's painful.

*edit
Not sure do web page hold connection open long time. They maybe use database in less second.

Last edited by Bacardi; 10-01-2021 at 13:19.
Bacardi is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 10-01-2021 , 14:14   Re: fail to connect to db due to more than 'max_user_connections' active connections
Reply With Quote #7

Quote:
Originally Posted by Bacardi View Post
Easy option would be increase your mysql server max_user_connections.

Or you would encounter this same problem later with different plugins.

...rewrite plugins with less connections ? It's painful.

*edit
Not sure do web page hold connection open long time. They maybe use database in less second.
yea i know but i can't increase the max_user_connections
guess i need to start looking for a new host
__________________
8guawong is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:55.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode