Raised This Month: $51 Target: $400
 12% 

OciXCrom's Rank System [XP|Levels|Ranks]


Post New Thread Reply   
 
Thread Tools Display Modes
LithuanianJack
Senior Member
Join Date: Nov 2013
Location: Vilnius, Lithuania
Old 02-24-2019 , 04:14   Re: OciXCrom's Rank System [XP|Levels|Ranks]
Reply With Quote #201

I'm saving data to MySQL and when there are a lot of people in my server (for example 25), I see error from server:

PHP Code:
[crx_ranksystem.amxx] [SQL ErrorConnection failed (1203): User user_ranking already has more than 'max_user_connections' active connections 

With other plugins who is connecting to SQL, everything is fine. I do not need to increase max_user_connections limit because problem is in plugin.

Last edited by LithuanianJack; 02-24-2019 at 04:15.
LithuanianJack is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 02-24-2019 , 07:51   Re: OciXCrom's Rank System [XP|Levels|Ranks]
Reply With Quote #202

You're using other SQL plugins, but are those plugins reading data for all players at once? This one does, so you should try increasing the limit. Also try changing line 1115:

PHP Code:
new Handle:iQuery SQL_PrepareQuery(iSqlConnection"SELECT * FROM %s WHERE Player = '%s';"g_eSettings[SQL_TABLE], szPlayer
To this:

PHP Code:
new Handle:iQuery SQL_PrepareQuery(iSqlConnection"SELECT XP FROM %s WHERE Player = '%s';"g_eSettings[SQL_TABLE], szPlayer
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
totopizza
AlliedModders Donor
Join Date: Oct 2015
Location: Honduras
Old 02-24-2019 , 17:33   Re: OciXCrom's Rank System [XP|Levels|Ranks]
Reply With Quote #203

https://dev.mysql.com/doc/refman/8.0...resources.html
totopizza is offline
LithuanianJack
Senior Member
Join Date: Nov 2013
Location: Vilnius, Lithuania
Old 02-25-2019 , 01:03   Re: OciXCrom's Rank System [XP|Levels|Ranks]
Reply With Quote #204

Quote:
Originally Posted by OciXCrom View Post
You're using other SQL plugins, but are those plugins reading data for all players at once? This one does, so you should try increasing the limit. Also try changing line 1115:

PHP Code:
new Handle:iQuery SQL_PrepareQuery(iSqlConnection"SELECT * FROM %s WHERE Player = '%s';"g_eSettings[SQL_TABLE], szPlayer
To this:

PHP Code:
new Handle:iQuery SQL_PrepareQuery(iSqlConnection"SELECT XP FROM %s WHERE Player = '%s';"g_eSettings[SQL_TABLE], szPlayer
Quote:
Originally Posted by totopizza View Post
My max_user_connections limit is 100 and I am not allowed to increase this value because of hosting provider. :/

I was using another plugin which selected and inserted players data at the real time and then I reached this connections limit but then I changed the code and saved data only at death event and everything was fine but in your plugin I do not know what to change to reach the result..

I tried to change this line but nothing changes.
PHP Code:
new Handle:iQuery SQL_PrepareQuery(iSqlConnection"SELECT XP FROM %s WHERE Player = '%s';"g_eSettings[SQL_TABLE], szPlayer

Last edited by LithuanianJack; 02-25-2019 at 01:05.
LithuanianJack is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 02-25-2019 , 15:55   Re: OciXCrom's Rank System [XP|Levels|Ranks]
Reply With Quote #205

Data is saved when the player disconnects. Saving it at death is redundant since it will get saved multiple times per game, instead of only once. Of course, when the map changes, it will save the data for all players at once since they all get disconnected from the server.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
LithuanianJack
Senior Member
Join Date: Nov 2013
Location: Vilnius, Lithuania
Old 02-26-2019 , 04:09   Re: OciXCrom's Rank System [XP|Levels|Ranks]
Reply With Quote #206

My hosting provider told me that possible problem is in plugin. Maybe inactive SQL connections is not closed by MySQL_close function and accumulates inactive (sleep) connections to database, finally max_user_connections limit is reached.
LithuanianJack is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 02-26-2019 , 13:24   Re: OciXCrom's Rank System [XP|Levels|Ranks]
Reply With Quote #207

There's no "MySQL_close" function in AMXX. Google tells me there was at once point, probably in some very old AMXX version (10+ years ago).
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
LithuanianJack
Senior Member
Join Date: Nov 2013
Location: Vilnius, Lithuania
Old 03-14-2019 , 03:00   Re: OciXCrom's Rank System [XP|Levels|Ranks]
Reply With Quote #208

You forgot to add SQL_FreeHandle(g_iSqlTuple) function at plugin_end(), and that's not enough, I still didn't solved this problem.

When player disconnects, sleepy (inactive) connection is still there - it should not be so.

This error appears when player disconnects >100 times at the same map. Inactive connections are reason why I reach max_user_connections limit.
LithuanianJack is offline
DruGzOG
Veteran Member
Join Date: Nov 2007
Location: Unknown
Old 03-16-2019 , 17:27   Re: OciXCrom's Rank System [XP|Levels|Ranks]
Reply With Quote #209

Quote:
Originally Posted by LithuanianJack View Post
You forgot to add SQL_FreeHandle(g_iSqlTuple) function at plugin_end(), and that's not enough, I still didn't solved this problem.

When player disconnects, sleepy (inactive) connection is still there - it should not be so.

This error appears when player disconnects >100 times at the same map. Inactive connections are reason why I reach max_user_connections limit.
He's spot on about this. Running the plugin and having the same issue to the point that there are idle connections as well.

PHP Code:
L 03/16/2019 13:32:38: [crx_ranksystem.amxxToo many connections
L 03
/16/2019 13:33:09: [crx_ranksystem.amxxToo many connections
L 03
/16/2019 13:33:11: [crx_ranksystem.amxx] [SQL ErrorConnection failed (1040): Too many connections 
Max connections is around 450. Running this and admin_sql.amxx. Nothing else.
Looking at the code, there isn't anything really closing the sql connections, is there?

Edit: Looks like its a default amxx problem ~
__________________

Last edited by DruGzOG; 03-16-2019 at 19:16.
DruGzOG is offline
Send a message via AIM to DruGzOG
totopizza
AlliedModders Donor
Join Date: Oct 2015
Location: Honduras
Old 03-17-2019 , 04:07   Re: OciXCrom's Rank System [XP|Levels|Ranks]
Reply With Quote #210

Try this, reduce the number of times a connection is created, now only create once:

Test it (I did not try it, but it should work):
Attached Files
File Type: sma Get Plugin or Get Source (crx_ranksystem_test_sql.sma - 469 views - 47.5 KB)
totopizza is offline
Reply



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 21:43.


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