AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   General (https://forums.alliedmods.net/forumdisplay.php?f=7)
-   -   SQL_ThreadQuery stop server in restart or amx_map if mysql server goes offline (https://forums.alliedmods.net/showthread.php?t=249945)

Arkshine 12-11-2014 18:30

Re: SQL_ThreadQuery stop server in restart or amx_map if mysql server goes offline
 
Thanks for testing. I have honestly no idea. Looking at google, it seems to be a misconfiguration or similar.

Like: http://stackoverflow.com/questions/5...n-packet-syste

All I can say is to make sure you have properly configured your mysql server infos.
Also did you set a timeout feature, and rw_timeout? Maybe it could help to play with it, because by default it's set to 0, so it's supposed to be a default undefined value, but it won't hurt to define one.

Cv3 12-12-2014 04:37

Re: SQL_ThreadQuery stop server in restart or amx_map if mysql server goes offline
 
Well on my tests as the guy above said, it do reconnects faster. The problem comes on the first connect where bunch of query tasks are executed (map launch).
I've read for the problem as well and tried almost everything I found out about - none of it worked. Good news is after binding only 1 of my IPs (external not local) to the mysql, the older version of this module returns almost no errors with plugins like amxbans where there was constant problem with the query for checking if player is flagged.

GuruQA 12-12-2014 09:24

Re: SQL_ThreadQuery stop server in restart or amx_map if mysql server goes offline
 
On my server is without error

But my server hosted in Brazil led ddos attacks and blocked the database IP USA

Result: my server crashed when changing map

I had to disable the plugin

Also has the problem if you connect 10 servers with different IPs on the same server

All HLDS will use only 1 IP
If the mysql block single IP
all Servers are left without access

GuruQA 02-12-2015 10:22

Re: SQL_ThreadQuery stop server in restart or amx_map if mysql server goes offline
 
There's another problem

When I change the map in a crowded server
The server is off a few seconds
Waiting send the information to mysql

No one knows a way to stop sending information when changing the map?

Arkshine 02-18-2015 13:41

Re: SQL_ThreadQuery stop server in restart or amx_map if mysql server goes offline
 
Guys, can try git4623+?

A fix has been applied to make sql*module more reactive and should flush everything fast at map change. (https://github.com/alliedmodders/amxmodx/pull/207).

It should, I hope, help such situation described in above posts.

^SmileY 02-18-2015 13:51

Re: SQL_ThreadQuery stop server in restart or amx_map if mysql server goes offline
 
Quote:

Originally Posted by Arkshine (Post 2263700)
Guys, can try git4623+?

A fix has been applied to make sql*module more reactive and should flush everything fast at map change. (https://github.com/alliedmodders/amxmodx/pull/207).

It should, I hope, help such situation described in above posts.

Yes we can let me re-activate my stats plugin :D

claudiuhks 02-18-2015 23:10

Re: SQL_ThreadQuery stop server in restart or amx_map if mysql server goes offline
 
Quote:

Originally Posted by Cv3 (Post 2234097)
Code:

Lost connection to MySQL server at 'reading initial communication packet', system error: 11
This comes and goes around using the last attachment on a debian wheezy 5.5 mysql and all the mods using mysql are loaded from time to time.

This is a MySQL server problem, not a problem of AMX Mod X's MySQL module.
I haven't seen this error even if I manually Killed mysqld.exe process in my computer (MySQL server) while the game server was running and executing queries. While the MySQL server was off-line, the game server said that it's unable to connect. When I started mysqld.exe process (MySQL server), everything went normal.
Even if the MySQL server dies 4-5 times in a few minutes, the game server should change map in a few milliseconds, or 1-2 seconds at most. As I tested in my PC.

And trust me, I did like 15 queries per second just to stress it.

GuruQA 02-20-2015 03:30

Re: SQL_ThreadQuery stop server in restart or amx_map if mysql server goes offline
 
I tested the amxmodx-1.8.3-dev-git4625 windows and gave the same error


I sent queries "SQL_ThreadQuery Select" with mysql off and stopped the hlds

GuruQA 02-20-2015 04:35

Re: SQL_ThreadQuery stop server in restart or amx_map if mysql server goes offline
 
I analyzed your test

Have you tested with the local IP 127.0.0.1

Makes a test with this IP:

Code:

// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
//    https://alliedmods.net/amxmodx-license
 
#include amxmodx
#include sqlx
 
// SQL credentials
#define HOST "200.149.119.103"
#define USER "root"
#define PASSWORD "<???>"
#define DATABASE "hattrick"
 
// Should never reach here
#define QUEUE_TIME_FOR_WARNING 5.0
 
new Handle:g_Tuple;
new Array:g_startedThreads;
new g_finishedThreads = 0;
 
public plugin_init()
{
        register_plugin("SQL Stress Test", "1.0", "Hattrick (HttrckCldHKS)");
 
        // This array will be filled in with threads that have been started
        g_startedThreads = ArrayCreate();
 
        // Stress SQL natives 5 times a second
        set_task(0.2, "stressSQL", .flags = "b");
}
 
public stressSQL()
{
        // Stress MakeDbTuple
        g_Tuple = SQL_MakeDbTuple(HOST, USER, PASSWORD, DATABASE);
 
        if (g_Tuple == Empty_Handle)
        {
                // Less probable you reach here...
                log_amx("SQL_MakeDbTuple Failed!");
                return;
        }
 
        // Stress Connect
        new errorId, Error[512], \
                Handle:Connection = SQL_Connect(g_Tuple, errorId, Error, charsmax(Error));
 
        if (Connection == Empty_Handle || errorId || Error[0])
        {
                // Only reach here if MySQL server is down
                log_amx("SQL_Connect Failed! errorId = %d | Error = %s", errorId, Error);
                goto doThreadQuery;
        }
 
        // Stress PrepareQuery
        new Handle:Query = SQL_PrepareQuery(Connection, "CREATE TABLE IF NOT EXISTS Developers (Name TEXT);");
        SQL_Execute(Query);
        SQL_FreeHandle(Query);
 
        Query = SQL_PrepareQuery(Connection, "CREATE TABLE IF NOT EXISTS Developers (Name TEXT);");
        SQL_Execute(Query);
        SQL_FreeHandle(Query);
 
        Query = SQL_PrepareQuery(Connection, "INSERT INTO Developers VALUES ('Arkshine');");
        SQL_Execute(Query);
        SQL_FreeHandle(Query);
 
        Query = SQL_PrepareQuery(Connection, "INSERT INTO Developers VALUES ('Hattrick');");
        SQL_Execute(Query);
        SQL_FreeHandle(Query);
 
        SQL_FreeHandle(Connection);
 
        // Stress ThreadQuery
doThreadQuery:
        SQL_ThreadQuery(g_Tuple, "displayFunction", "SELECT * FROM Developers ORDER BY Name DESC LIMIT 10;");
 
        // Mark this threaded query as started
        ArrayPushCell(g_startedThreads, 1);
}
 
// Display some data, as a test
public displayFunction(failState, Handle:Query, Error[], errorId, Data[], dataSize, Float:queueTime)
{
        // Only reach here if there is no connection or invalid query
        if (failState || errorId || Error[0])
                log_amx("SQL_ThreadQuery Failed! FailState = %d | Error = %s | errorId = %d", failState, Error, errorId);
 
        else
        {
                if (SQL_NumRows(Query))
                {
                        // Stress results
                        while (SQL_MoreResults(Query))
                        {
                                new Name[512];
                                SQL_ReadResult(Query, 0, Name, charsmax(Name));
 
                                SQL_NextRow(Query);
                        }
 
                        // Rewind from zero
                        SQL_Rewind(Query);
 
                        // Stress again
                        while (SQL_MoreResults(Query))
                        {
                                new Name[512];
                                SQL_ReadResult(Query, 0, Name, charsmax(Name));
 
                                SQL_NextRow(Query);
 
                                // Print
                                server_print(Name);
                        }
                }
 
                // Get field's name
                new fieldName[512];
                SQL_FieldNumToName(Query, 0, fieldName, charsmax(fieldName));
 
                server_print(fieldName);
        }
 
        // Should never reach here
        if (queueTime > QUEUE_TIME_FOR_WARNING)
                server_print("Attention! QueueTime == %f", queueTime);
 
        // This threaded query was finished
        g_finishedThreads++;
}
 
public plugin_end()
{
        if (g_Tuple != Empty_Handle)
                SQL_FreeHandle(g_Tuple);
 
        // Compare to see if all threads succeeded
        new startedThreads = ArraySize(g_startedThreads);
        if (g_finishedThreads != startedThreads)
        {
                // Now... you will probably reach here if there is no Internet connection...
                // Of course, this message will be displayed, but dont worry :
                // X = startedThreads - g_finishedThreads
                // So, after this message is displayed, you will see X new messages (while OnPluginsUnloading()), being displayed
                // They will be SQL_ThreadQuery's Handlers being executed after this plug-in's plugin_end() forward.
                // They'll more than probably say :  No internet connection or TQuery failed.
                server_print("Problem at PluginEnd() :  %d threads have been started but only %d were executed...", \
                        startedThreads, g_finishedThreads);
                // So, everything is going to be executed, and much more faster than before.
        }
}


claudiuhks 02-20-2015 04:57

Re: SQL_ThreadQuery stop server in restart or amx_map if mysql server goes offline
 
PHP Code:

L 02/20/2015 11:54:22: [x.amxxSQL_Connect FailederrorId 2003 Error Can't connect to MySQL server on '200.149.119.103' (10060)
L 02/20/2015 - 11:54:22: [x.amxx] SQL_ThreadQuery Failed! FailState = -2 | Error = Can'
t connect to MySQL server on '200.149.119.103' (10060) | errorId 2003
L 02
/20/2015 11:54:43: [x.amxxSQL_Connect FailederrorId 2003 Error Can't connect to MySQL server on '200.149.119.103' (10060)
L 02/20/2015 - 11:55:04: [x.amxx] SQL_Connect Failed! errorId = 2003 | Error = Can'
t connect to MySQL server on '200.149.119.103' (10060)
L 02/20/2015 11:55:04: [x.amxxSQL_ThreadQuery FailedFailState = -Error Can't connect to MySQL server on '200.149.119.103' (10060) | errorId = 2003 

Are you sure hostname, username, password and database are correct?
You can send them to me, temporary, in a private message if you want.


All times are GMT -4. The time now is 21:01.

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