amxmodx icon indicating copy to clipboard operation
amxmodx copied to clipboard

SQL_ThreadQuery hangs the server when changing the map

Open Nelpsen opened this issue 5 years ago • 10 comments

The server starts to wait, when the queue from the accumulated SQL_ThreadQuery will be completed or will not be timed out, if the database is unavailable, the server will freeze and will wait.

There is no such problem in sourcemod, the card change does not wait for the queue to end, and after the card change the queue continues to try to send requests.

AMXModX 1.9.0

Nelpsen avatar Jun 04 '20 13:06 Nelpsen

The server starts to wait, when the queue from the accumulated SQL_ThreadQuery will be completed or will not be timed out, if the database is unavailable, the server will freeze and will wait.

There is no such problem in sourcemod, the card change does not wait for the queue to end, and after the card change the queue continues to try to send requests.

AMXModX 1.9.0

I'm pretty sure Source mod does the same thing if the database is unavailable. Can confirm its happened when we switched hosts and had to wait for our databases to migrate.

This is normal behavior, honestly don't see a solution or method to fix this.

xLeviNx avatar Jun 06 '20 02:06 xLeviNx

The server starts to wait, when the queue from the accumulated SQL_ThreadQuery will be completed or will not be timed out, if the database is unavailable, the server will freeze and will wait. There is no such problem in sourcemod, the card change does not wait for the queue to end, and after the card change the queue continues to try to send requests. AMXModX 1.9.0

I'm pretty sure Source mod does the same thing if the database is unavailable. Can confirm its happened when we switched hosts and had to wait for our databases to migrate.

This is normal behavior, honestly don't see a solution or method to fix this.

Do not wait for the completion of the request queue at the time of the card change, but continue to execute the queue after the card is changed.

Nelpsen avatar Jun 06 '20 12:06 Nelpsen

What query your plugin is running? You can explain better? To be honest i think that can be fixed using other moment to save the data than map change.

SmileYzn avatar Jun 12 '20 00:06 SmileYzn

What query your plugin is running? You can explain better? To be honest i think that can be fixed using other moment to save the data than map change.

The status of the players is updated during disconnect, the disconnect of all players is triggered when the card is changed. If the database is unavailable, the server will wait for the queue to complete.

The workaround was to change the mysql_timeout cvar to 5 seconds.

There is a small fix for the module; when a card is changed, the queue is recorded temporarily in a file and, after its change, continues to attempt execution.

Nelpsen avatar Jun 12 '20 10:06 Nelpsen

It was what I was going to suggest. Anyway SQL do not have a better design to save players data.

SmileYzn avatar Jun 12 '20 11:06 SmileYzn

Are you sure that you are not missed thread query with Execute's(which are blocking)? Can you provide any examples?

If you run SQL_ThreadQuery in plugin_end event, server will hang until the query return results to handler.

SmileYzn avatar Jul 17 '20 12:07 SmileYzn

Ok, im gonna check, im pretty sure that u are wrong.

afwn90cj93201nixr2e1re avatar Jul 17 '20 19:07 afwn90cj93201nixr2e1re

@SmileYzn ok, u are right, yes, external sleep on mysql causing server also stop working (on mapchanges only, yes) (not actualy stoped, just slept for 20 seconds)...

That's strange. So, we need to implement SQL_ThreadQuery2 for real non-blocking, but rn SQL_ThreadQuery fixing problem that when we close connection (on server deactivate post) on mysql queries in queues also dropped without execution. But actually they aren't blocking on nonmap changes as u said, it's ok for me, just ask dvander for some suggestions, idk, he implemented this.

afwn90cj93201nixr2e1re avatar Jul 17 '20 21:07 afwn90cj93201nixr2e1re

SQL_ThreadQuery is just based on ServerFrame also some code on OnPluginsUnloading, while this is there, can't be "fixed".

SmileYzn avatar Jul 18 '20 02:07 SmileYzn

AMX Mod X unloads plugins on map change, which means flushing database queues. SourceMod persists plugins across maps. You'd see the same problem on SourceMod if you tried to unload the plugin.

Probably the only option here would be to specify that some queries are allowed to complete with no feedback (eg if it succeeds or fails, the plugin would never know).

dvander avatar Jul 18 '20 02:07 dvander