No active cache - MySQL
#1

Long time no see.

I've recently gotten into mysql from y_ini, since I am an owner of a server that my friend had and he had a mysql script. Now, for some reason, it says no active cache in the mysql_logs when someone tries logging in and it loses connection the server. This therefore makes it so no one can log in. Here is the mysql_log:

Код:
[05:04:41] [DEBUG] >> mysql_ping(Connection handle: 1)
[05:04:41] [DEBUG] CMySQLHandler::Ping() - Connection is still alive.
[05:04:56] [DEBUG] >> mysql_ping(Connection handle: 1)
[05:04:56] [DEBUG] CMySQLHandler::Ping() - Connection is still alive.
[05:04:59] [DEBUG] >> mysql_real_escape_string(Connection handle: 1)
[05:04:59] [DEBUG] CMySQLHandler::EscapeString(Nathan_Lucado) - Escaped 13 characters to Nathan_Lucado.
[05:05:00] [DEBUG] >> mysql_query_callback(Connection handle: 1)
[05:05:00] [DEBUG] ProcessQueryThread(OnQueryFinish) - Executing query SELECT * FROM `bans` WHERE `IP_Address` = '69.14.156.1' LIMIT 0, 1...
[05:05:00] [DEBUG] ProcessQueryThread(OnQueryFinish) - Query was successful.
[05:05:00] [DEBUG] ProcessQueryThread(OnQueryFinish) - Data being passed to ProcessTick().
[05:05:00] [DEBUG] OnQueryFinish(siii) - Callback is being called...
[05:05:00] [DEBUG] >> cache_get_data(Connection handle: 1)
[05:05:00] [WARNING] >> cache_get_data(...) - There is no active cache.
[05:05:00] [DEBUG] >> mysql_query_callback(Connection handle: 1)
[05:05:00] [WARNING] ProcessQueryThread() - Lost connection, reconnecting to the MySQL-server in the background thread.
[05:05:00] [DEBUG] CMySQLHandler::Connect() - Connection was successful.
[05:05:00] [DEBUG] CMySQLHandler::Connect() - Auto-reconnect has been enabled.
[05:05:00] [DEBUG] ProcessQueryThread(OnQueryFinish) - Executing query SELECT * FROM `accounts` WHERE `Username` = 'Nathan_Lucado' LIMIT 0, 1...
[05:05:00] [DEBUG] ProcessQueryThread(OnQueryFinish) - Query was successful.
[05:05:00] [DEBUG] ProcessQueryThread(OnQueryFinish) - Data being passed to ProcessTick().
[05:05:00] [DEBUG] OnQueryFinish(siii) - Callback is being called...
[05:05:00] [DEBUG] >> cache_get_data(Connection handle: 1)
[05:05:00] [WARNING] >> cache_get_data(...) - There is no active cache.
[05:05:11] [DEBUG] >> mysql_ping(Connection handle: 1)
[05:05:11] [ERROR] CMySQLHandler::Ping() - An error has occured (error: 2014, Commands out of sync; you can't run this command now).
[05:05:11] [DEBUG] >> mysql_reconnect(Connection handle: 1)
[05:05:11] [DEBUG] CMySQLHandler::Disconnect() - Connection was closed.
[05:05:12] [DEBUG] CMySQLHandler::Connect() - Connection was successful.
[05:05:12] [DEBUG] CMySQLHandler::Connect() - Auto-reconnect has been enabled.
[05:05:27] [DEBUG] >> mysql_ping(Connection handle: 1)
[05:05:27] [DEBUG] CMySQLHandler::Ping() - Connection is still alive.
[05:05:42] [DEBUG] >> mysql_ping(Connection handle: 1)
[05:05:42] [DEBUG] CMySQLHandler::Ping() - Connection is still alive.
Now, the code for the areas I am assuming is the problem (seeing as it only happens when logging in) are these:

pawn Код:
//When logging in, under custom OnPlayerConnected timer
    format(szQuery, sizeof(szQuery), "SELECT * FROM `bans` WHERE `IP_Address` = '%s' LIMIT 0, 1", GetPlayerIPAddress(playerid));
    mysql_query(szQuery, THREAD_IP_LOOKUP, playerid, mConnectionHandle);

//On the OnQueryFinish public callback or whatevs.
//At the top of the callback
new
        rowCount,
        fieldCount;
    cache_get_data(rowCount, fieldCount, connectionHandle);
    switch (resultid)
    {
case THREAD_IP_LOOKUP: //No problem here
        {
//blablabla
}

// The actual login part.  It loses connection and then automatically goes to the "else" statement that says "this account appears to be available!"
        case THREAD_ACCOUNT_LOOKUP:
        {
            new
                szValue[256];
            if (rowCount > 0)
            {
                mysql_retrieve_row(connectionHandle);
                cache_get_field_content(0, "Password", PlayerInfo[extraid][pPassword], connectionHandle);
                LoadPlayerAccount(extraid, connectionHandle);
                format(szValue, sizeof(szValue), "{FFFFFF}Hello %s, this account appears to be {FF0000}registered!\n{FFFFFF}Please type in the correct password to access this account:", PlayerInfo[extraid][pUsername]);
                ShowPlayerDialogEx(extraid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, SERVER_NAME" - Login", szValue, "Login", "Exit");
            } else {
                if(!IsRPName(extraid))
                {
                    SendClientMessage(extraid, COLOR_YELLOW, "You have joined the server with an invalid roleplay name!");
                    SendClientMessage(extraid, COLOR_YELLOW, "Please choose a valid name such as: John_Doe!");
                    Kick(extraid);
                }
                else
                {
                    format(szValue, sizeof(szValue), "{FFFFFF}Hello %s, this account appears to be {00FF1E}available!\n{FFFFFF}Please type in a valid password to register this account:", PlayerInfo[extraid][pUsername]);
                    ShowPlayerDialogEx(extraid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, SERVER_NAME" - Registration", szValue, "Register", "Exit");
                }
            }
Sorry about the bad indention, you know how copy/pasting can do. And I am in a hurry, so I don't have the time to correct it. If someone could help, it would be really appreciated.

Thanks,
Kindred
Reply
#2

The macro definition (mysql_query macro) always has caching disabled, thus there is no cache. Use the proper mysql_function_query function and make sure to set caching to true. Cache functions also cannot be used together with regular functions.
Reply
#3

Alright. What about commands out of sync? Because I assume that the "no active cache" warning isn't really what's causing me to not be able to log in. It just started happening, after updating my script with some mapping and adding a few commands that had nothing to do with mysql.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)