Raised This Month: $32 Target: $400
 8% 

Solved SQL related crashes?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sneaK
SourceMod Moderator
Join Date: Feb 2015
Location: USA
Old 01-17-2017 , 19:26   SQL related crashes?
Reply With Quote #1

Hey guys, I've been working with a heavily modified timer recently, and I've been trying to work through some crashes. They don't happen immediately (once every hour or so), and generally only happens with lots of clients connected (25+). Can anyone grasp what might be going on based on these accelerator logs?

https://crash.limetech.org/ptyyhkeovnti
https://crash.limetech.org/5uhnsiwg5bwk

No error logs, the best I could find was a brief database connection loss prior to the first crash.
__________________

Last edited by sneaK; 01-20-2017 at 01:48.
sneaK is offline
wwahgnerbp
Member
Join Date: Mar 2013
Location: Earth, Solar System
Old 01-17-2017 , 20:29   Re: SQL related crashes?
Reply With Quote #2

did you set timeout in the database config? maybe the engine is making too much queries xD

ps: I'll skip that part of threaded sql queries because you may know already so....

Last edited by wwahgnerbp; 01-17-2017 at 20:34. Reason: ps
wwahgnerbp is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 01-17-2017 , 22:05   Re: SQL related crashes?
Reply With Quote #3

The crash reports have stuff after mysql callbacks.

1. Memory leaks?
2. Bad code in a callback
__________________
Neuro Toxin is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 01-20-2017 , 01:19   Re: SQL related crashes?
Reply With Quote #4

Are you mixing threaded and non-threaded queries?
__________________
Peace-Maker is offline
sneaK
SourceMod Moderator
Join Date: Feb 2015
Location: USA
Old 01-20-2017 , 01:48   Re: SQL related crashes?
Reply With Quote #5

Quote:
Originally Posted by Peace-Maker View Post
Are you mixing threaded and non-threaded queries?
As a matter of fact yes, just did some testing using only threaded queries and the issue seems to be resolved. I'm assuming it's a bad mix?

Thank you guys!
__________________
sneaK is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 01-20-2017 , 12:57   Re: SQL related crashes?
Reply With Quote #6

Just always use threaded queries. There are natives to lock the database connection, so you can make sure no threaded query is executed while you're executing your non-threaded one, but that caused people lots of problems in the past.
__________________
Peace-Maker is offline
wwahgnerbp
Member
Join Date: Mar 2013
Location: Earth, Solar System
Old 01-21-2017 , 11:40   Re: SQL related crashes?
Reply With Quote #7

Quote:
Originally Posted by Peace-Maker View Post
Just always use threaded queries. There are natives to lock the database connection, so you can make sure no threaded query is executed while you're executing your non-threaded one, but that caused people lots of problems in the past.
Would you mind if I ask you why non-threaded queries are so problematic?
wwahgnerbp is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 01-21-2017 , 13:00   Re: SQL related crashes?
Reply With Quote #8

The mysqlclient doesn't like executing two queries at the same time in different threads. If you run a non-threaded query in your plugin you might run it along a threaded query that's been queued. Leading to weird errors or crashes.

You could use the SQL_LockDatabase and SQL_UnlockDatabase natives to avoid that, but if your plugin fails to unlock the database somehow, no further threaded queries will be executed on your database handle.
Not calling UnlockDatabase in early returns or having a script error aborting execution before the unlock call confused script developers, since they often don't know what they're doing when dealing with threads and sourcepawn usually being single threaded.
__________________
Peace-Maker is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 01-21-2017 , 13:33   Re: SQL related crashes?
Reply With Quote #9

Rather than using SQL_LockDatabase and SQL_UnlockDatabase, a much better solution is to open 2 connections (well, the best solution is to only ever use threaded queries - blocking the game thread is bad).
__________________
asherkin is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:58.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode