My game server is facing freezing issues with threaded queries in the queue on map change event with my rented MySQL server.
I understand the threaded queries take a bit longer to process when connected to a MySQL server remotely compared to a MySQL on a local/home network, but upon map change event, why doesn't it stop all the threaded queries in the queue at this point?
Video demonstration:
0:00-1:09 is when I'm using my rented MySQL.
1:09-16 is when I'm using a MySQL on my local network.
I used this to reproduce this issue:
Code:
#include <amxmodx>#include <amxmisc>#include <sqlx>new Handle:g_SqlX
public plugin_init(){set_task(0.1, "sql_init")}public sql_init(){new error[128], errno
SQL_SetAffinity("mysql")
g_SqlX = SQL_MakeStdTuple()new Handle:dbConnect = SQL_Connect( g_SqlX, errno, error, charsmax(error))if( dbConnect == Empty_Handle ){server_print("-- DEBUG: ERROR: Cannot connect to SQL!")return}
SQL_FreeHandle(dbConnect)}public plugin_end(){
g_SqlX = Empty_Handle
}public client_putinserver(id){new szAuthID[35], szIP[16], szQuery[512]get_user_authid( id, szAuthID, charsmax(szAuthID))get_user_ip( id, szIP, charsmax(szIP), 1)
formatex( szQuery, charsmax(szQuery), "SELECT COUNT(*) FROM `amx_bans` WHERE ((player_id='%s' AND ban_type='S') OR (player_ip='%s' AND ban_type='SI')) AND expired = 1", szAuthID, szIP )for(new i =0; i <=32; i++)// Instead of getting 32 players to the server, you can reproduce it with this loop{if( g_SqlX )
SQL_ThreadQuery( g_SqlX, "ThreadHandler", szQuery )}return PLUGIN_HANDLED;
}public ThreadHandler(failstate, Handle:query, error[], errnum, data[], size, Float:queuetime){server_print("-- DEBUG: Resolved query %d, took %f seconds", data[0], queuetime )if( failstate ){if( failstate == TQUERY_CONNECT_FAILED ){server_print("-- DEBUG: Connection failed!")}elseif( failstate == TQUERY_QUERY_FAILED ){server_print("-- DEBUG: Query failed!")}server_print("-- DEBUG: Error code: %d (Message: ^"%s^")", errnum, error )new querystring[512]
SQL_GetQueryString( query, querystring, charsmax(querystring))server_print("-- DEBUG: Original query: %s", querystring )}}
I have tested this on both Windows (10) and Linux (Ubuntu 18.04.4 LTS) with AMX Mod X 1.9 (build 5263) and AMX Mod X 1.10 (build 5390); no difference.