SphereServer BugTracker - SphereServer
View Issue Details
0001921SphereServerexecutable - linux buildpublic27-02-11 17:4606-08-14 12:10
trinax 
XuN 
normalmajorsometimes
closedfixed 
LinuxDebian5.0
20-09-2009, 0.56b Prerelease 
0.56c Nightly 
Automated (specify build number)
DiagonalWalkCheck, New_Triggers, WalkCheck, AllowTelnetPacketFilter, NetworkOutThread
Command_Sysmsgs, FileCommands
1420
0001921: 'Main' thread hang if db.query used too much
I have a script that opens up a dialog that uses db.query when players go into war mode. Sometimes the thing below happens:

16:35:P'Feto' was killed by P'Biscuit'.
16:36:CRITICAL:(event.scp,6787)'Main' thread hang, restarting...

and after the thread restart, logs have the script name on every line:
16:48:(event.scp,6787)World save completed, took 1.0000 seconds

Line 6787 is:
db.query "select name, killamount, uid from the_table where team=2 order by killamount desc";
It is inside a dialog.

Going war mode has a cooldown of a few secs during the event but still this happens when too many people hit tab at the same time I think.

I may be wrong but I think when this happens for the second time without a complete restart, sphere crashes with no error.

No tags attached.
Issue History
27-02-11 17:46trinaxNew Issue
13-03-11 04:14MrSugarCubeNote Added: 0000957
13-03-11 10:00trinaxNote Added: 0000961
13-03-11 13:18trinaxNote Edited: 0000961bug_revision_view_page.php?bugnote_id=0000961#r179
23-07-14 19:48XuNNote Added: 0002366
06-08-14 12:10XuNStatusnew => closed
06-08-14 12:10XuNAssigned To => XuN
06-08-14 12:10XuNResolutionopen => fixed
06-08-14 12:10XuNFixed in Version => 0.56c Nightly

Notes
(0000957)
MrSugarCube   
13-03-11 04:14   
What is the value of the FreezeRestartTime setting in sphere.ini?

I expect that the cause of this is that there's too much processing going on in the script (and/or the database isn't returning the results fast enough) and Sphere thinks that the process has frozen.

Increasing FreezeRestartTime may help. Another option could be to use asynchronous queries (db.aquery/aexecute) if the query is taking a long time to finish.
(0000961)
trinax   
13-03-11 10:00   
(edited on: 13-03-11 13:18)
FreezeRestartTime is 15 seconds. The table usually has 30~rows only. I have just noticed there is two queries in the dialog. Each of them is working with a <local> like this.

db.query "select name, k, serial from cs where team=1 order by k desc";
if (<db.row.numrows> > 0)
for x 0 <eval <db.row.numrows>-1>
local.ct <local.ct><db.row.<dlocal.x>.name> - <db.row.<dlocal.x>.k> <qval <db.row.<dlocal.x>.serial>?- [DEAD]:><def.br>
endfor
endif
db.query "select name, k, serial from cs where team=2 order by k desc";
if (<db.row.numrows> > 0)
for x 0 <eval <db.row.numrows>-1>
local.ct <local.ct><db.row.<dlocal.x>.name> - <db.row.<dlocal.x>.k> <qval <db.row.<dlocal.x>.serial>?- [DEAD]:><def.br>
endfor
endif

I will try melting the two queries together and see if it is fixed then.

(0002366)
XuN   
23-07-14 19:48   
If the MySQL server is not on the same machine you should try to use aquery, or you'll have to wait until the data come back. If this is not the case ... is it still happening?