Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysql_close doesn't wait until mysql_tquery has been executed #64

Closed
AkinoKiritani opened this issue May 24, 2015 · 7 comments
Closed

Comments

@AkinoKiritani
Copy link

mysql_close is only waiting until the query which was called with mysql_pquery has been executed.

I don't know whether this is desirable.

@maddinat0r
Copy link
Collaborator

Are you talking about R39-3?

@maddinat0r
Copy link
Collaborator

If you are indeed talking about R39-3: mysql_close doesn't handle specific connections in any special way. Here you can see that a Disconnect function is passed to the MySQL handler, where the handler calls that function with all internal MySQL server connections. The connection system queues all calls regarding connections (to make sure that all MySQL API calls are called in their corresponding connection/query-processing threads) and executes them here. Here you can also see that the function call gets queued again if it returns false, and the Disconnect() function always returns false if there are still unexecuted queries.
Well, that's the theory. As you see, it's very unlikely that only queries sent through mysql_pquery are executed at disconnection.

@AkinoKiritani
Copy link
Author

Sorry, for the late response.

Yes - I'm talking about R39-3.
I did some tests in the last days, and every time while an gmx and the call of mysql_close.
pquerys will be executed to the database, tquerys not.

No idea why.

Maybe, this log will help.

[12:10:19] [DEBUG] mysql_format - connection: 1, len: 150, format: "UPDATE `User` SET `PosX` = %.3f, `PosY` = %.3f, `PosZ` = %.3f, `Angle` = %.3f, `Adminrank` = %d WHERE `uID` = %d LIMIT 1;"
[12:10:19] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `User` SET `PosX` = 11.232, `PosY` = -113.564, `PosZ` = 0", callback: "(null)", format: "(null)"
[12:10:19] [DEBUG] mysql_close - connection: 1
[12:10:19] [DEBUG] CMySQLConnection::Disconnect - connection was closed
[12:10:19] [DEBUG] CMySQLConnection::Disconnect - connection was closed
[12:10:19] [DEBUG] CMySQLHandle::~CMySQLHandle - deconstructor called
[12:10:31] [DEBUG] mysql_connect - host: "****", user: "****", database: "****", password: "****", port: 3306, autoreconnect: true, pool_size: 2
[12:10:31] [DEBUG] CMySQLHandle::Create - creating new connection..
[12:10:31] [DEBUG] CMySQLHandle::CMySQLHandle - constructor called
[12:10:31] [DEBUG] CMySQLHandle::Create - connection created (id: 1)
[12:10:31] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[12:10:32] [DEBUG] CMySQLConnection::Connect - connection was successful
[12:10:32] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[12:12:12] [DEBUG] mysql_format - connection: 1, len: 150, format: "UPDATE `User` SET `PosX` = %.3f, `PosY` = %.3f, `PosZ` = %.3f, `Angle` = %.3f, `Adminrank` = %d WHERE `uID` = %d LIMIT 1;"
[12:12:12] [DEBUG] mysql_pquery - connection: 1, query: "UPDATE `User` SET `PosX` = 8.559, `PosY` = -162.411, `PosZ` = 0.", callback: "(null)", format: "(null)"
[12:12:12] [DEBUG] mysql_close - connection: 1
[12:12:12] [DEBUG] CMySQLConnection::Disconnect - connection was closed
[12:12:12] [DEBUG] CMySQLConnection::Disconnect - connection was closed
[12:12:12] [DEBUG] CMySQLHandle::~CMySQLHandle - deconstructor called
[12:12:24] [DEBUG] mysql_connect - host: "****", user: "****", database: "****", password: "****", port: 3306, autoreconnect: true, pool_size: 2
[12:12:24] [DEBUG] CMySQLHandle::Create - creating new connection..
[12:12:24] [DEBUG] CMySQLHandle::CMySQLHandle - constructor called
[12:12:24] [DEBUG] CMySQLHandle::Create - connection created (id: 1)
[12:12:24] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[12:12:25] [DEBUG] CMySQLConnection::Connect - connection was successful
[12:12:25] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[12:12:25] [DEBUG] mysql_errno - connection: 1

@maddinat0r
Copy link
Collaborator

It looks like neither the pquery-query nor the tquery-query are executed (query execution is always logged if debug logging is enabled).
Could you try to insert a delay between the mysql_tquery/mysql_pquery and mysql_close call?
e.g.

public OnGameModeExit()
{
    mysql_tquery(g_MySQL, "UPDATE something");
    new tc = tickcount();
    while((tickcount() - tc) < 3000) //pause server for 3 seconds
    { }
    mysql_close(g_MySQL);
    return 1;
}

@AkinoKiritani
Copy link
Author

Yes, with pause it's working with tquery.

@maddinat0r
Copy link
Collaborator

Could you share the log output again please?

@AkinoKiritani
Copy link
Author

[18:38:48] [DEBUG] CMySQLHandle::DeleteSavedResult - result deleted
[18:38:58] [DEBUG] mysql_format - connection: 1, len: 150, format: "UPDATE `User` SET `PosX` = %.3f, `PosY` = %.3f, `PosZ` = %.3f, `Angle` = %.3f, `Adminrank` = %d WHERE `uID` = %d LIMIT 1;"
[18:38:58] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `User` SET `PosX` = 157.573, `PosY` = -71.546, `PosZ` = 1", callback: "(null)", format: "(null)"
[18:38:58] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[18:38:58] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 108.550 milliseconds
[18:38:58] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving
[18:39:01] [DEBUG] mysql_close - connection: 1
[18:39:01] [DEBUG] CMySQLConnection::Disconnect - connection was closed
[18:39:01] [DEBUG] CMySQLConnection::Disconnect - connection was closed
[18:39:01] [DEBUG] CMySQLConnection::Disconnect - connection was closed
[18:39:01] [DEBUG] CMySQLHandle::~CMySQLHandle - deconstructor called
[18:39:10] [DEBUG] mysql_connect - host: "****", user: "****", database: "****", password: "****", port: 3306, autoreconnect: true, pool_size: 2
[18:39:10] [DEBUG] CMySQLHandle::Create - creating new connection..
[18:39:10] [DEBUG] CMySQLHandle::CMySQLHandle - constructor called
[18:39:10] [DEBUG] CMySQLHandle::Create - connection created (id: 1)
[18:39:10] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[18:39:10] [DEBUG] CMySQLConnection::Connect - connection was successful
[18:39:10] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[18:39:10] [DEBUG] mysql_errno - connection: 1
[18:39:10] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[18:39:10] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[18:39:10] [DEBUG] CMySQLConnection::Connect - establishing connection to database...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants