PDA

View Full Version : Reason for XP being reset discovered


AdamR
3rd April 2008, 01:39
I found out today why XP gets reset to level 0 (with -1 medals)...

AMXX's SQL module makes a new connection for each query it executes. It also does not close the connection after the query has finished. This leaves a lot of sleeping connections about from our game servers to the SQL server just waiting to timeout.

If a map comes on that gives loads of XP, many many connections are made because each time you level up, a save query is performed. Too many queries made means any new ones will get rejected with the error "too many connections". This effects loading your XP, saving your XP, and the web site.

If you join a server while there are too many connections, SCXPM will not be able to load your XP and therefore you have nothing. Later on when the connections die down, you leave the server, and your reset XP is saved. That is how you end up with nothing.

If you join a server and see yourself with 0 XP, leave right away or it will be saved like that. Inforn us (preferibly via IRC (http://sc.multiplay.co.uk/irc.php)) of the problem.

The kick in the nuts is there is nothing we can do about it as it's the SQL module's fault, not the individual plugins using it. The SQL module needs to use persistent connections, so that each game server only keeps 1 connection alive and runs all it's queries through the one connection it has. Please support this feature request (http://bugs.alliedmods.net/index.php?do=details&task_id=1557) to get persistent connections in to AMXX.

Increasing the maximum number of connections won't solve much. It would just mean more resources are required.

Say_Ten
3rd April 2008, 07:26
Even closing the connection after each query would help given that description :(

AdamR
3rd April 2008, 07:47
It would help very much. I'd like to meet the guy who wrote the SQL module and find out why he/she decided not to close connections after each query, or why persistent connections isn't an option in the first place.

The only alternative is if our SQL servers had a lower timeout.

AMXX is entirely open source, although written in C++ (which I'm not experienced in). It's possible for us to modify the module ourselves.

Quietus
3rd April 2008, 11:09
As far as I can see, the SQL module doesn't autoclose connections because it is creating persistent connections. The functions are present in the module to reuse existing connections anyway. I'm having a look through the complete XP saving call to see what the full process is now.

AdamR
3rd April 2008, 11:31
We'd need to look at the AMXX mysqlx module source instead to see why plugins aren't using the same connection, wouldn't we?

thelinx
4th April 2008, 06:33
I voted for :>

Jolene
4th April 2008, 23:08
It would help very much. I'd like to meet the guy who wrote the SQL module and find out why he/she decided not to close connections after each query, or why persistent connections isn't an option in the first place.

Sounds like they learnt C++ at the Microsoft School of Programming Excellence ¬_¬

Night HawK
23rd July 2008, 12:45
I thought I lost medals for swearing but it must of been that luckily it was when I just started...or maybe it was because I sweared