[Plugin] [REL] MySQL Plugin (Now on github!)

Good Job G-sTyLeZzZ.

+1 Rep for you.
Reply

The plugin does not work on R5 for me.
Reply

Is it possible to connect 2 databases ( in the GM)? database 1 = accounts, database 2 = bans.
mysql_connect("123.456.789", "DB1", "AA");
mysql_connect("123.456.789", "DB2", "BB");

With the php I believe it's possible. Thx.
Reply

Quote:
Originally Posted by ombre
Посмотреть сообщение
Is it possible to connect 2 databases ( in the GM)? database 1 = accounts, database 2 = bans.
mysql_connect("123.456.789", "DB1", "AA");
mysql_connect("123.456.789", "DB2", "BB");

With the php I believe it's possible. Thx.
why aren't you reading the first post ppl ?

Код:
//this example demonstrates how to use more connections
new SQLPtr[2]; //global var
...
Function()
{
   SQLPtr[0] = mysql_connect(...);
   SQLPtr[1] = mysql_connect(...);
   mysql_query("SELECT a FROM table WHERE foo = 'bar'",(-1),(-1),SQLPtr[0]); //select query in the first DB
   mysql_query("UPDATE b SET bar = 'foo'",(-1),(-1),SQLPtr[1]); //update query in the second DB
   mysql_close(SQLPtr[1]); //close the 2nd DB connection, the other connection still exists
Reply

ok sry not seen. But I dont really understand. There are a GM or other with?
Reply

I've tested mysql_connect on two databases, with SA-MP 0.3c R5 server

Код:
[20:34:59] CMySQLHandler::Query() - You cannot call this function now. (Reason: Connection is dead)
It both gives this. I can tell you it simply works fine on my previous version (0.3c R2 server)
Reply

good job worked perfectly to me
Reply

another small problem.. R6

my server kinda like.. disconnects from the mysql server around 27 - 35 seconds after connection.. this only happens when I gmx

edit: its offical, threads/callbacks are freezing( locking up ) the server.. (it doesn't always happen)

second time now

pawn Код:
[05:18:28] CMySQLHandler::ProcessQueryThread(SELECT * FROM Drug_Plants WHERE Owner = 'Harry') - Data is getting passed to OnQueryFinish() - (Threadsafe: Yes)
other time, (previous page)

pawn Код:
[16:02:06] CMySQLHandler::Query("OnUserLogin") - Custom callback query with index 102 started (ExtraID: -1)
passwords like "ииит ртпрн" is making the mysql lost connection during the query? >.<

some more logs..
pawn Код:
[13:41:55] >> mysql_real_escape_string( Connection handle: 1 )
[13:41:55] CMySQLHandler::EscapeString(Galamonkey); - Escaped 10 characters to Galamonkey.
[13:41:55] >> mysql_query( Connection handle: 1 )
[13:41:55] CMySQLHandler::Query(resultID) - Threaded query with id 3 started. (Extra ID: 8)
[13:41:55] >> mysql_real_escape_string( Connection handle: 1 )
[13:41:55] CMySQLHandler::EscapeString(Peter_Toman); - Escaped 11 characters to Peter_Toman.
[13:41:55] >> mysql_query( Connection handle: 1 )
[13:41:55] CMySQLHandler::ProcessQueryThread(SELECT * FROM Drug_Plants WHERE Owner = 'Galamonkey') - Data is getting passed to OnQueryFinish() - (Threadsafe: Yes)
[13:41:55] CMySQLHandler::Query(UPDATE `Accounts` SET `WantedLevel` = 3 WHERE `Username` = 'Peter_Toman') - An error has occured. (Error ID: 2013, Lost connection to MySQL server during query)
[13:41:55] OnQueryError() - Called.
[13:41:55] >> mysql_reconnect( Connection handle: 1 )
[13:41:55] CMySQLHandler::Disconnect() - Connection was closed.
[13:41:55] CMySQLHandler::Connect() - Connection was successful.
[13:41:55] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.
[13:41:55] OnQueryFinish(3,"SELECT * FROM Drug_Plants WHERE Owner = 'Galamonkey'") - Called.
[13:41:55] >> mysql_store_result( Connection handle: 1 )
[13:41:55] CMySQLHandler::StoreResult() - No data to store.
[13:41:55] >> mysql_num_rows( Connection handle: 1 )
[13:41:55] CMySQLHandler::NumRows() - You cannot call this function now. (Reason: Dead Connection)
[13:41:55] >> mysql_retrieve_row( Connection handle: 1 )
[13:41:55] CMySQLHandler::RetrieveRow() - You cannot call this function now. (Reason: Empty Result)
[13:41:55] >> mysql_free_result( Connection handle: 1 )
[13:41:55] CMySQLHandler::FreeResult() - The result is already empty.
Reply

Hmm, I don't think that incldue was updated to R6 in R6 package (and include is missing in R6-2 package).

And another thing. I wonder why mysql_log was renamed to Debug. I liked original name more
Reply

Hey, was just searching the forums for a solution and this guy had the same problem..

http://forum.sa-mp.com/showthread.ph...=onqueryfinish

edit: a user with the EXACT same problem as me

Quote:
Originally Posted by Alice[WS]
Посмотреть сообщение
Nice plugin

I wanted to know, since i've threaded some queries my server freezes sometimes. By checking in the logs i can find "Data is getting passed to OnQueryFinish() - (Threadsafe: No)".
What does that "Threadsafe: No" mean ? I think it has something to do with the MySQL server's configuration, the threaded queries cannot execute in the specified thread, but i am not sure.

If it has an importance, how could i activate it ?

Thanks in advance.
edit 2: another user!

http://forum.sa-mp.com/showthread.ph...sh#post1269390

* Yes, I know those posts are from R5, it's just an example.

I believe its Linux only

BEFORE ANYONE SHOWS ME WHAT BLUEG SAID

Quote:
Originally Posted by G-sTyLeZzZ
Посмотреть сообщение
The plugin has been updated after almost one year once again due to a threading bug which was discovered by xxmitsu. I have added mutexes to make sure shared variables don't get accessed twice by different threads at the same time. (which causes random crashes) Besides that I have made some code improvements and fixed some small bugs.

I advice everyone who uses the threading capabilities to update to R6, the files are as usual in the first post.

Great thanks for this release goes to xxmitsu for testing and compiling the plugin on Debian5 and CentOS.
The bug is back!
Reply

Thanks for this plugin.
Very useful.
Reply

Quote:
Originally Posted by Donya
Посмотреть сообщение
Hey, was just searching the forums for a solution and this guy had the same problem..

The bug is back!
That bug caused the server to crash not to loose the connection to database. Is your mysql server on the same host as the samp server is ? because otherwise it could be packet loss issue between the samp host and mysql server. I'm not using R6-2 in production yet(I'm using R6). But I've tested R6-2 and didn't experienced any of your problems.


Are you using threded queries mixed with standard queries ?(if yes, it could be the problem) are you freeing the results after storing them ?
Also:
Код:
[13:41:55] OnQueryError() - Called.
check your query sintax seems like there is an error somewhere.

--
EDIT: I've just read that this problem only appears on gmx. Well, I can't tell you for sure because I NEVER gmx. I always prefer killing/restarting the server process.
Reply

I'm not using R6-2 because it doesn't have a CentOS download.

yes I am freeing results after storing them

I use like a callback for onuserlogin, then a thread for loading groups and drug plants(when a player spawns), others are standard queries.

I never GMX on the real host.
Reply

Quote:
Originally Posted by Donya
Посмотреть сообщение
I never GMX either.
Quote:
Originally Posted by Donya
Посмотреть сообщение
another small problem.. R6

my server kinda like.. disconnects from the mysql server around 27 - 35 seconds after connection.. this only happens when I gmx
I don't get it.

And like I said.. check what cause OnQueryError to be called.
Reply

oh sorry, that was on my windows test server, but otherwise forget that. The crashing is coming from the linux real host, whereas about atleast 13+ players are online when it happens

Edit: Didn't I post the query logs already... and this is my onqueryerror

pawn Код:
public OnQueryError(errorid, error[], resultid, extraid, callback[], query[], connectionHandle)
{
    switch(errorid)
    {
        case CR_COMMAND_OUT_OF_SYNC: {
            mysql_free_result();
            printf("[Mysql Error] - Commands Out Of Sync For Thread ID: %d", resultid);
        }
        case ER_UNKNOWN_TABLE: printf("[Mysql Error] - Unknown table '%s' in %s", error, query);
        case ER_SYNTAX_ERROR: printf("[Mysql Error] - Something is wrong in your syntax, query: %s", query);
        case CR_SERVER_GONE_ERROR: mysql_reconnect();
        case CR_SERVER_LOST: mysql_reconnect();
        case CR_SERVER_LOST_EXTENDED: mysql_reconnect();
    }
    if(errorid == CR_SERVER_LOST && resultid == THREAD_INITIATE_GROUPS) mysql_query("SELECT * FROM Groups", THREAD_INITIATE_GROUPS);
    printf("EID: %d | Error: %s | Query: %s", errorid, error, query);
    return 1;
}
as you can see.. the error with lost / gone_error are the ones that are being called..
Reply

Quote:
Originally Posted by xxmitsu
Посмотреть сообщение
Are you using threded queries mixed with standard queries ?(if yes, it could be the problem) are you freeing the results after storing them ?
[...]
EDIT: I've just read that this problem only appears on gmx. Well, I can't tell you for sure because I NEVER gmx. I always prefer killing/restarting the server process.
Would threading every single query possibly fix the lockups/freezing issues? And yes, I can confirm that at least 7 GMXes out of 10 lock the server up.
Reply

I can't pronounce myself regarding the gmx issue because I'm not using gmx. But perhaps using threaded with non-treaded queries can lead to unexpected results (I don't know this either because all my queries are threded - was just an suggestion).
Reply

Quote:
Originally Posted by xxmitsu
Посмотреть сообщение
I can't pronounce myself regarding the gmx issue because I'm not using gmx. But perhaps using threaded with non-treaded queries can lead to unexpected results (I don't know this either because all my queries are threded).
wow every single one? well.. hmm.. This problem actually didn't exist in R4-5... I must say( well for me obviously )

and again I say, this happens my host that's running on linux, not the windows. I never gmxed or even clicked the "restart" button on my host, it's stop then start.

I was gmxing on windows to try to find a bug in my onplayerconnect and saw that the mysql server disconnects, that isn't a problem with the lockups
Reply

Thanks AndreT,

i tested with Debian-mysqlR6-normal.tar.gz and the error is gone.
I have ia32-libs already installed.

But now i get this error:
Failed (libmysqlclient_r.so.16: cannot open shared object file: No such file or directory)

In startpost is only the libmysqlclient.so.15.
libmysqlclient16 is installed in the newest version.



Now starts my server, and if a player join i get this message in console:
./samp03svr: symbol lookup error: plugins/mysql.so: undefined symbol: compress


greetings
Reply

Quote:
Originally Posted by jig
Посмотреть сообщение
Thanks AndreT,

i tested with Debian-mysqlR6-normal.tar.gz and the error is gone.
I have ia32-libs already installed.

But now i get this error:
Failed (libmysqlclient_r.so.16: cannot open shared object file: No such file or directory)

In startpost is only the libmysqlclient.so.15.
libmysqlclient16 is installed in the newest version.



Now starts my server, and if a player join i get this message in console:
./samp03svr: symbol lookup error: plugins/mysql.so: undefined symbol: compress


greetings
install openssl devel or try the static build. It's too bad that I haven't had the time to test all of them in production.

But on my servers I'm running R6-static both CentOS and Debian.
Reply


Forum Jump:


Users browsing this thread: 14 Guest(s)