Server crashes when loading from DB -
dusk - 31.03.2013
I was doing this and that and, the server crashes!
Tried some stuff and found out, that my "LoadBusiness" function crashes it (without it used it works). But I don't see whats wrong with it,please take a look
pawn Код:
stock LoadBusiness()
{
for(new i; i<MAX_BUSINESS; i++)
{
new query[64],string[64];
format(query,sizeof(query),"SELECT * FROM `Business` WHERE bizid = %d",i);
mysql_query(query);
mysql_store_result();
if(mysql_num_rows() != 0)
{
mysql_fetch_row_format(query,"|");
sscanf(query,"p<|>e<ds[64]dds[64]dddffffffdds[24]d>",BizInfo[i]);
if(BizInfo[i][Owned]==0) {format(string,sizeof(string),"Verslas parduodamas\nKaina %d",BizInfo[i][Price]);}
else if(BizInfo[i][Owned]>0) {format(string,sizeof(string),"%s\nIejimo kaina %d",BizInfo[i][BizName],BizInfo[i][EntrancePrice]);}
BizInfo[i][HouseLabel]=Create3DTextLabel(string,0xFFFF00FF,BizInfo[i][enX],BizInfo[i][enY],BizInfo[i][enZ],25,BizInfo[i][VirtualWorld]);
}
}
mysql_free_result();
return 1;
}
Its only called on GameModeInit.
Re: Server crashes when loading from DB -
Scenario - 31.03.2013
Assuming your maximum amount of businesses is like 100, you'd be handling 100 queries at OnGameModeInit(). Without threaded queries, your server is going to hang.
This code retrieves ALL of the data from the "businesses" table and handles it accordingly.
pawn Код:
stock LoadBusiness()
{
new string[64];
mysql_query("SELECT * FROM `Business`");
mysql_store_result();
for(new i = 0; i < mysql_num_rows(); i++)
{
mysql_fetch_row_format(query,"|");
sscanf(query,"p<|>e<ds[64]dds[64]dddffffffdds[24]d>",BizInfo[i]);
if(BizInfo[i][Owned]==0) format(string,sizeof(string),"Verslas parduodamas\nKaina %d",BizInfo[i][Price]);
else if(BizInfo[i][Owned]>0) format(string,sizeof(string),"%s\nIejimo kaina %d",BizInfo[i][BizName],BizInfo[i][EntrancePrice]);
BizInfo[i][HouseLabel]=Create3DTextLabel(string,0xFFFF00FF,BizInfo[i][enX],BizInfo[i][enY],BizInfo[i][enZ],25,BizInfo[i][VirtualWorld]);
}
mysql_free_result();
return 1;
}
P.S: You really should be using threaded queries. People writing new code that doesn't use threaded queries are just hurting themselves in the long run. Not to mention, it's pretty idiotic.
Re: Server crashes when loading from DB -
dusk - 31.03.2013
That was not the problem...The server still crashes although it now only has to handle 1query...
About those threaded things. I'd love to use the R7 plugin..but i don't understand it. What is that "connection handler" used everywhere.
Re: Server crashes when loading from DB -
iggy1 - 31.03.2013
The connection handle is returned by
mysql_connect. So you can connect to different dbs or have different connections to the same db ECT.
Re: Server crashes when loading from DB -
dusk - 31.03.2013
Thanks I think i'll give it another go..
But,my server still crashes
Re: Server crashes when loading from DB -
Scenario - 31.03.2013
Is MySQL debugging enabled? If so, post the contents of the mysql_log.txt file.
If not, add this just before the mysql_connect() line in OnGameModeInit(): mysql_debug(1);
Re: Server crashes when loading from DB -
dusk - 31.03.2013
PHP код:
[20:09:33] MySQL Debugging activated (03/31/13)
[20:09:33] ---------------------------
[20:09:33]
[20:09:33] >> mysql_connect( )
[20:09:33] CMySQLHandler::CMySQLHandler() - constructor called.
[20:09:33] CMySQLHandler::CMySQLHandler() - Connecting to "localhost" | DB: "bebras" | Username: "bebras" ...
[20:09:33] CMySQLHandler::Connect() - Connection was successful.
[20:09:33] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.
[20:09:33] >> mysql_query( Connection handle: 1 )
[20:09:33] CMySQLHandler::Query(SELECT * FROM Global) - Successfully executed.
[20:09:33] >> mysql_store_result( Connection handle: 1 )
[20:09:33] CMySQLHandler::StoreResult() - Result was stored.
[20:09:33] >> mysql_fetch_row_format( Connection handle: 1 )
[20:09:33] CMySQLHandler::FetchRow() - Return: 1|258
[20:09:33] >> mysql_fetch_row_format( Connection handle: 1 )
[20:09:33] >> mysql_query( Connection handle: 1 )
[20:09:33] CMySQLHandler::Query(SELECT * FROM houses) - Successfully executed.
[20:09:33] >> mysql_store_result( Connection handle: 1 )
[20:09:33] CMySQLHandler::StoreResult() - Result was stored.
[20:09:33] >> mysql_num_rows( Connection handle: 1 )
[20:09:33] CMySQLHandler::NumRows() - Returned 8 row(s)
[20:09:33] >> mysql_fetch_row_format( Connection handle: 1 )
[20:09:33] CMySQLHandler::FetchRow() - Return: 12|Enrico_Mancini|1|5000|-185.054|952.153|16.9541|-1861.94|54.9081|1061.14|14|0||0
[20:09:33] >> mysql_num_rows( Connection handle: 1 )
[20:09:33] CMySQLHandler::NumRows() - Returned 8 row(s)
[20:09:33] >> mysql_fetch_row_format( Connection handle: 1 )
[20:09:33] CMySQLHandler::FetchRow() - Return: 13||0|500005|-195.993|952.818|16.5186|140.17|1366.07|1083.65|2|0||0
[20:09:33] >> mysql_num_rows( Connection handle: 1 )
[20:09:33] CMySQLHandler::NumRows() - Returned 8 row(s)
[20:09:33] >> mysql_fetch_row_format( Connection handle: 1 )
[20:09:33] CMySQLHandler::FetchRow() - Return: 14|Enrico_Mancini|1|50003|-187.022|989.149|19.406|2324.53|-1149.54|1050.71|3|0||0
[20:09:33] >> mysql_num_rows( Connection handle: 1 )
[20:09:33] CMySQLHandler::NumRows() - Returned 8 row(s)
[20:09:33] >> mysql_fetch_row_format( Connection handle: 1 )
[20:09:33] CMySQLHandler::FetchRow() - Return: 15|Enrico_Mancini|1|50003|-184.702|978.718|19.1922|2324.53|-1149.54|1050.71|3|0||0
[20:09:33] >> mysql_num_rows( Connection handle: 1 )
[20:09:33] CMySQLHandler::NumRows() - Returned 8 row(s)
[20:09:33] >> mysql_fetch_row_format( Connection handle: 1 )
[20:09:33] CMySQLHandler::FetchRow() - Return: 16||0|123456|-182.578|1001.83|19.7266|226.3|1114.24|1080.99|6|0||0
[20:09:33] >> mysql_num_rows( Connection handle: 1 )
[20:09:33] CMySQLHandler::NumRows() - Returned 8 row(s)
[20:09:33] >> mysql_fetch_row_format( Connection handle: 1 )
[20:09:33] CMySQLHandler::FetchRow() - Return: 17|Enrico_Mancini|1|10000|-195.886|981.662|19.105|83.03|1322.28|1083.87|9|0||0
[20:09:33] >> mysql_num_rows( Connection handle: 1 )
[20:09:33] CMySQLHandler::NumRows() - Returned 8 row(s)
[20:09:33] >> mysql_fetch_row_format( Connection handle: 1 )
[20:09:33] CMySQLHandler::FetchRow() - Return: 18|Enrico_Mancini|1|5001|-168.503|975.288|18.1878|243.72|304.91|999.15|1|0||0
[20:09:33] >> mysql_num_rows( Connection handle: 1 )
[20:09:33] CMySQLHandler::NumRows() - Returned 8 row(s)
[20:09:33] >> mysql_fetch_row_format( Connection handle: 1 )
[20:09:33] CMySQLHandler::FetchRow() - Return: 19||0|13216|-153.088|977.934|18.4233|299.78|309.89|1003.3|4|0||0
[20:09:33] >> mysql_num_rows( Connection handle: 1 )
[20:09:33] CMySQLHandler::NumRows() - Returned 8 row(s)
[20:09:33] >> mysql_free_result( Connection handle: 1 )
[20:09:33] CMySQLHandler::FreeResult() - Result was successfully free'd.
[20:09:33] >> mysql_query( Connection handle: 1 )
[20:09:33] CMySQLHandler::Query(SELECT * FROM `Business`) - Successfully executed.
[20:09:33] >> mysql_store_result( Connection handle: 1 )
[20:09:33] CMySQLHandler::StoreResult() - Result was stored.
[20:09:33] >> mysql_num_rows( Connection handle: 1 )
[20:09:33] CMySQLHandler::NumRows() - Returned 1 row(s)
[20:09:33] >> mysql_fetch_row_format( Connection handle: 1 )
[20:09:33] CMySQLHandler::FetchRow() - Return: 0|Enrico_Mancini|1|123456|labas|0|0|20|0|0|2|2324.33|-1144.79|1050.71|12|0||0
[20:09:33] >> mysql_num_rows( Connection handle: 1 )
[20:09:33] CMySQLHandler::NumRows() - Returned 1 row(s)
[20:09:33] >> mysql_free_result( Connection handle: 1 )
[20:09:33] CMySQLHandler::FreeResult() - Result was successfully free'd.
There's no problems here....i think
Re: Server crashes when loading from DB -
dusk - 31.03.2013
I updated to mysql R8.This is the last thing that happens:
pawn Код:
[00:27:14] ProcessTick() - The cache has been cleared.
[00:27:37] >> mysql_query_callback(Connection handle: 1)
[00:27:37] ProcessQueryThread(OnAccountCheck) - Executing query SELECT password FROM `users` WHERE `username` = 'Enrico_Mancini'...
[00:27:37] ProcessQueryThread(OnAccountCheck) - Query was successful.
[00:27:37] ProcessQueryThread(OnAccountCheck) - Data caching enabled.
[00:27:37] CMySQLHandler::StoreResult() - Result was stored.
[00:27:37] CMySQLHandler::FreeResult() - Result was successfully freed.
[00:27:37] ProcessQueryThread(OnAccountCheck) - Data being passed to ProcessTick().
[00:27:37] OnAccountCheck(i) - Callback has been called.
[00:27:37] >> cache_get_data(Connection handle: 1)
pawn Код:
forward OnAccountCheck(playerid);
public OnAccountCheck(playerid)
{
new rows,fields;
cache_get_data(rows,fields,dbHandle);
if(rows>0)
{
cache_get_row(0,3,PlayerInfo[playerid][pPass],dbHandle);
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login:","Enter your password below:","Login","Cancel");
}
else
{
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_PASSWORD,"Register:","Enter your pasword below:","Register","Cancel");
}
return 1;
}
EDIT:crashdetect log
pawn Код:
01:02:30] [debug] Server crashed while executing rp.amx
[01:02:30] [debug] AMX backtrace:
[01:02:30] [debug] #0 native cache_get_row () [00138ce0] from mysql.so
[01:02:30] [debug] #1 000246c4 in public OnAccountCheck () from rp.amx
[01:02:30] [debug] System backtrace:
[01:02:30] [debug] #0 00fd1ecb in _ZN10StackTraceC1EPv () from plugins/crashdetect.so
[01:02:30] [debug] #1 00fc9c69 in _ZN11CrashDetect20PrintSystemBacktraceEPv () from plugins/crashdetect.so
[01:02:30] [debug] #2 00fcbc99 in _ZN11CrashDetect11OnExceptionEPv () from plugins/crashdetect.so
[01:02:30] [debug] #3 00fd19d8 in ?? () from plugins/crashdetect.so
[01:02:30] [debug] #4 0082c600 in ?? ()
[01:02:30] [debug] #5 00ea62eb in strlen () from /lib/libc.so.6
[01:02:30] [debug] #6 08094ce5 in ?? () from ./bebrassamp
[01:02:30] [debug] #7 00133342 in amx_SetString () from plugins/mysql.so
[01:02:30] [debug] #8 001336e0 in _ZN6StrAmx10SetCStringEP6tagAMXiPci () from plugins/mysql.so
[01:02:30] [debug] #9 00138d75 in _ZN7Natives15n_cache_get_rowEP6tagAMXPi () from plugins/mysql.so
[01:02:30] [debug] #10 080938e4 in ?? () from ./bebrassamp
[01:02:30] [debug] #11 00fcbf37 in _ZN11CrashDetect13DoAmxCallbackEiPiS0_ () from plugins/crashdetect.so
[01:02:30] [debug] #12 00fce268 in ?? () from plugins/crashdetect.so
[01:02:30] [debug] #13 00fd42c2 in amx_Exec () from plugins/crashdetect.so
[01:02:30] [debug] #14 00fcbe1e in _ZN11CrashDetect9DoAmxExecEPii () from plugins/crashdetect.so
[01:02:30] [debug] #15 00fce2de in ?? () from plugins/crashdetect.so
[01:02:30] [debug] #16 00132c21 in amx_Exec () from plugins/mysql.so
[01:02:30] [debug] #17 0013cda9 in ProcessTick () from plugins/mysql.so
[01:02:30] [debug] #18 080c5a32 in ?? () from ./bebrassamp
[01:02:30] [debug] #19 080b57fc in ?? () from ./bebrassamp
[01:02:30] [debug] #20 080b10a3 in ?? () from ./bebrassamp
[01:02:30] [debug] #21 00e49c76 in __libc_start_main () from /lib/libc.so.6
[01:02:30] [debug] #22 0804b521 in ?? () from ./bebrassamp
Re: Server crashes when loading from DB -
dusk - 01.04.2013
sorry for bumping this early...but i REALLY need help with this!