SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 11/04/2015, 01:27 PM   #1
MEW273
Big Clucker
 
MEW273's Avatar
 
Join Date: Jan 2015
Location: Australia
Posts: 149
Reputation: 13
Default [MySQL R39-3] MySQL losing connection during query

Basically, I have created my GM and am starting with the login system, once I start my server I can successfully connect and login successfully no worries, but when I leave the game and re-connect I get an error in my MySQL log (error #2013) Lost connection to MySQL server during query

I have tried:
I found in one thread that someone recommended using separate MySQL connections for different queries, that did not work.
I tried formatting my queries without the `ID` quotes, that also did not work.

This seems to be the sequence of events that lead to the error, the full log is below in the code tag.
[17:28:50] [DEBUG] mysql_format - connection: 1, len: 128, format: "SELECT `ID`, `Username`, `Password` FROM `accounts` WHERE `Username` = '%s'"
[17:28:50] [DEBUG] mysql_pquery - connection: 1, query: "SELECT `ID`, `Username`, `Password` FROM `accounts` WHERE `Username` = 'Jason_West'", callback: "OnQueryFinish", format: "ii"
[17:28:50] [DEBUG] CMySQLQuery::Execute[OnQueryFinish] - starting query execution
[17:28:50] [ERROR] CMySQLQuery::Execute[OnQueryFinish] - (error #2013) Lost connection to MySQL server during query

As you can see in the below code the exact same query as above works when first used, but will not work again.
[17:26:50] [DEBUG] mysql_format - connection: 1, len: 128, format: "SELECT `ID`, `Username`, `Password` FROM `accounts` WHERE `Username` = '%s'"
[17:26:50] [DEBUG] mysql_pquery - connection: 1, query: "SELECT `ID`, `Username`, `Password` FROM `accounts` WHERE `Username` = 'Jason_West'", callback: "OnQueryFinish", format: "ii"
[17:26:50] [DEBUG] CMySQLQuery::Execute[OnQueryFinish] - starting query execution
[17:26:50] [DEBUG] CMySQLQuery::Execute[OnQueryFinish] - query was successfully executed within 290.785 milliseconds


pawn Code:
[17:26:02] [DEBUG] mysql_option - option: 1, value: 0
[17:26:02] [DEBUG] mysql_connect - host: "blurred", user: "blurred", database: "blurred", password: "****", port: 3306, autoreconnect: true, pool_size: 2
[17:26:02] [DEBUG] CMySQLHandle::Create - creating new connection..
[17:26:02] [DEBUG] CMySQLHandle::CMySQLHandle - constructor called
[17:26:02] [DEBUG] CMySQLHandle::Create - connection created (id: 1)
[17:26:02] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[17:26:04] [DEBUG] CMySQLConnection::Connect - connection was successful
[17:26:04] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[17:26:04] [DEBUG] mysql_errno - connection: 1
[17:26:04] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[17:26:04] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[17:26:04] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[17:26:05] [DEBUG] CMySQLConnection::Connect - connection was successful
[17:26:05] [DEBUG] CMySQLConnection::Connect - connection was successful
[17:26:05] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[17:26:05] [DEBUG] CMySQLConnection::Connect - connection was successful
[17:26:05] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[17:26:50] [DEBUG] mysql_format - connection: 1, len: 128, format: "SELECT `ID`, `Username`, `Password` FROM `accounts` WHERE `Username` = '%s'"
[17:26:50] [DEBUG] mysql_pquery - connection: 1, query: "SELECT `ID`, `Username`, `Password` FROM `accounts` WHERE `Username` = 'Jason_West'", callback: "OnQueryFinish", format: "ii"
[17:26:50] [DEBUG] CMySQLQuery::Execute[OnQueryFinish] - starting query execution
[17:26:50] [DEBUG] CMySQLQuery::Execute[OnQueryFinish] - query was successfully executed within 290.785 milliseconds
[17:26:50] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[17:26:50] [DEBUG] Calling callback "OnQueryFinish"..
[17:26:50] [DEBUG] cache_get_row_count - connection: 1
[17:26:50] [DEBUG] cache_get_field_content_int - row: 0, field_name: "ID", connection: 1
[17:26:50] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "ID", data: "2"
[17:26:50] [DEBUG] cache_get_field_content - row: 0, field_name: "Username", connection: 1, max_len: 24
[17:26:50] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "Username", data: "Jason_West"
[17:26:50] [DEBUG] cache_get_field_content - row: 0, field_name: "Password", connection: 1, max_len: 32
[17:26:50] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "Password", data: "yolo"
[17:26:50] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[17:26:58] [DEBUG] mysql_format - connection: 1, len: 128, format: "SELECT * FROM `accounts` WHERE `Username` = '%s'"
[17:26:58] [DEBUG] mysql_pquery - connection: 1, query: "SELECT * FROM `accounts` WHERE `Username` = 'Mitchell_Weston'", callback: "OnQueryFinish", format: "ii"
[17:26:59] [DEBUG] CMySQLQuery::Execute[OnQueryFinish] - starting query execution
[17:26:59] [DEBUG] CMySQLQuery::Execute[OnQueryFinish] - query was successfully executed within 287.741 milliseconds
[17:26:59] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[17:26:59] [DEBUG] Calling callback "OnQueryFinish"..
[17:26:59] [DEBUG] cache_get_row_count - connection: 1
[17:26:59] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Admin", connection: 1
[17:26:59] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "Admin", data: "7"
[17:28:50] [DEBUG] mysql_format - connection: 1, len: 128, format: "SELECT `ID`, `Username`, `Password` FROM `accounts` WHERE `Username` = '%s'"
[17:28:50] [DEBUG] mysql_pquery - connection: 1, query: "SELECT `ID`, `Username`, `Password` FROM `accounts` WHERE `Username` = 'Jason_West'", callback: "OnQueryFinish", format: "ii"
[17:28:50] [DEBUG] CMySQLQuery::Execute[OnQueryFinish] - starting query execution
[17:28:50] [ERROR] CMySQLQuery::Execute[OnQueryFinish] - (error #2013) Lost connection to MySQL server during query
[17:28:50] [DEBUG] CMySQLQuery::Execute[OnQueryFinish] - error will be triggered in OnQueryError

OnQueryFinish code:
pawn Code:
case THREAD_CHECK_ACCOUNT:
            {
                new Rows;
                Rows = cache_get_row_count(gMySQL);
                if(Rows)
                {
                    PlayerData[extraid][ID] = cache_get_field_content_int(0, "ID");
                    cache_get_field_content(0, "Username", PlayerData[extraid][Username], gMySQL, 24);
                    cache_get_field_content(0, "Password", PlayerData[extraid][Password], gMySQL, 32);
                    new String[128];
                    format(String, sizeof(String), "Welcome %s. This account is registered. Please enter your password below to login.", GetPlayerRPN(extraid));
                    ShowPlayerDialog(extraid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", String, "Login", "Cancel");
                }
                else if (!Rows)
                {
                }
            }

OnPlayerConnect code:
pawn Code:
new PlayerName[24], Query[128];
    for(new i; Account:i < Account; i++)
    {
        PlayerData[playerid][Account:i] = 0;
    }
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    mysql_format(gMySQL, Query, sizeof(Query), "SELECT `ID`, `Username`, `Password` FROM `accounts` WHERE `Username` = '%s'", PlayerName);
    mysql_pquery(gMySQL, Query, "OnQueryFinish", "ii", THREAD_CHECK_ACCOUNT, playerid);

Last edited by MEW273; 11/04/2015 at 01:28 PM. Reason: updated title
MEW273 is offline   Reply With Quote
Old 13/04/2015, 07:40 AM   #2
MEW273
Big Clucker
 
MEW273's Avatar
 
Join Date: Jan 2015
Location: Australia
Posts: 149
Reputation: 13
Default Re: [MySQL R39-3] MySQL losing connection during query

BUMP, has been over 24 hours, still wondering if anyone can assist me in any way.
MEW273 is offline   Reply With Quote
Old 13/04/2015, 08:10 AM   #3
Darrenr
Big Clucker
 
Darrenr's Avatar
 
Join Date: Mar 2015
Posts: 90
Reputation: 13
Default Re: [MySQL R39-3] MySQL losing connection during query

Does the SQL server close down? Does it have a log-file with a bit more information?

And do you have to reset the samp server to get it working again?.... also, what happens if you log two players in one after the other (so playerid 0 and playerid 1 are tested with.. as appose to logging in with playerid 0 twice) does the 2nd player give the error?
__________________
PM me for help with scripting in Pawn.








rep+
Darrenr is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
MySql lost connection on query Maximus0 Scripting Help 3 10/02/2015 01:25 PM
Help Pls : Lost connection to MySQL server during query bigtigerbeee Scripting Help 4 12/01/2014 01:06 PM
Error ID: 2013, Lost connection to MySQL server during query nGen.SoNNy Server Support 1 22/09/2012 04:23 PM
Failed to exeute query. Lost connection to MySQL server during query. *IsBack Help Archive 10 06/01/2011 08:50 AM


All times are GMT. The time now is 08:12 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.