I have figured out if you make threaded queries too fast that the database will go away. I found this out by simulating a heavy traffic to see if it would handle the load.
Not to mention this crashes the server sometimes. This is a fresh install of the server I use to test my addons on.
Here's my test code
require( "mysql" )
local xdb, isok, error = mysql.connect("192.168.0.10", "****", "*****", "testdatabase")
local threadtable = {}
function querytest1()
local thread, isok, error = mysql.query(xdb, "SELECT 1 + 1 FROM servers", mysql.QUERY_NOBLOCK);
if(isok) then
table.insert(threadtable,thread)
print("Thread:" .. thread .. " made")
else
mysql.query_cleanup(thread)
end
timer.Simple(1,querytest1)
end
function querytest2()
local thread, isok, error = mysql.query(xdb, "SELECT 1 + 1 FROM servers", mysql.QUERY_NOBLOCK);
if(isok) then
table.insert(threadtable,thread)
print("Thread:" .. thread .. " made")
else
mysql.query_cleanup(thread)
end
timer.Simple(1,querytest2)
end
function querytest3()
local thread, isok, error = mysql.query(xdb, "SELECT 1 + 1 FROM servers", mysql.QUERY_NOBLOCK);
if(isok) then
table.insert(threadtable,thread)
print("Thread:" .. thread .. " made")
else
mysql.query_cleanup(thread)
end
timer.Simple(1,querytest3)
end
function querycallback(query)
local count = 0
local atable = {}
atable = table.Copy(threadtable)
for i,v in pairs(atable) do
count = count + 1
if(mysql.query_complete(v)) then
local result, isok, error = mysql.query_read(v)
mysql.query_cleanup(v)
if !isok then
print("THREAD FAILED")
print(error)
else
print("THREAD #" .. v .. " FINISHED")
print(result)
end
table.remove(threadtable,i)
else
print("THREAD NOT DONE")
end
end
PrintTable(threadtable)
timer.Simple(5, querycallback)
end
timer.Simple(1,querytest1)
timer.Simple(1,querytest2)
timer.Simple(1,querytest3)
timer.Simple(1,querytest1)
timer.Simple(1,querytest2)
timer.Simple(5, querycallback)