Raised This Month: $32 Target: $400
 8% 

SQL_ThreadQuery stop server in restart or amx_map if mysql server goes offline


Post New Thread Reply   
 
Thread Tools Display Modes
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-11-2014 , 18:30   Re: SQL_ThreadQuery stop server in restart or amx_map if mysql server goes offline
Reply With Quote #21

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.
__________________

Last edited by Arkshine; 12-11-2014 at 18:30.
Arkshine is offline
Cv3
Junior Member
Join Date: Sep 2014
Old 12-12-2014 , 04:37   Re: SQL_ThreadQuery stop server in restart or amx_map if mysql server goes offline
Reply With Quote #22

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.
Cv3 is offline
GuruQA
Member
Join Date: Oct 2014
Old 12-12-2014 , 09:24   Re: SQL_ThreadQuery stop server in restart or amx_map if mysql server goes offline
Reply With Quote #23

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 is offline
GuruQA
Member
Join Date: Oct 2014
Old 02-12-2015 , 10:22   Re: SQL_ThreadQuery stop server in restart or amx_map if mysql server goes offline
Reply With Quote #24

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?
GuruQA is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-18-2015 , 13:41   Re: SQL_ThreadQuery stop server in restart or amx_map if mysql server goes offline
Reply With Quote #25

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.
__________________

Last edited by Arkshine; 02-18-2015 at 13:42.
Arkshine is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 02-18-2015 , 13:51   Re: SQL_ThreadQuery stop server in restart or amx_map if mysql server goes offline
Reply With Quote #26

Quote:
Originally Posted by Arkshine View Post
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
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 02-18-2015 , 23:10   Re: SQL_ThreadQuery stop server in restart or amx_map if mysql server goes offline
Reply With Quote #27

Quote:
Originally Posted by Cv3 View Post
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.
__________________

Last edited by claudiuhks; 02-18-2015 at 23:15.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
GuruQA
Member
Join Date: Oct 2014
Old 02-20-2015 , 03:30   Re: SQL_ThreadQuery stop server in restart or amx_map if mysql server goes offline
Reply With Quote #28

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 is offline
GuruQA
Member
Join Date: Oct 2014
Old 02-20-2015 , 04:35   Re: SQL_ThreadQuery stop server in restart or amx_map if mysql server goes offline
Reply With Quote #29

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.
        }
}

Last edited by GuruQA; 02-20-2015 at 04:38.
GuruQA is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 02-20-2015 , 04:57   Re: SQL_ThreadQuery stop server in restart or amx_map if mysql server goes offline
Reply With Quote #30

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.
__________________
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
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 12:47.


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