• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.2 Crash might be caused by player_death

Line #19 of the stack trace:
SQL:
DELETE FROM `player_deaths` WHERE `player_id` = 3526 ORDER BY `time` LIMIT 1
It looks like your MySQL version does not support the DELETE LIMIT statement.

Consider changing the query in playerdeath.lua to:
Lua:
if limit > 0 then
    db.asyncQuery("DELETE FROM `player_deaths` WHERE `player_id` = player_id AND `killed_by` = killed_by AND `mostdamage_by` = mostdamage_by IN (SELECT `player_id`, `killed_by`, `mostdamage_by` FROM `player_deaths` WHERE `player_id` = " .. playerGuid .. " ORDER BY `time` LIMIT " .. limit .. ")")
end
(!! Disclaimer: untested and, moreover, my SQL knowledge is pretty rusty)

Alternatively, consider upgrading your MySQL server and/or your MySQL driver to a version that supports the DELETE LIMIT statement.
 
You got:
Code:
DELETE FROM `player_deaths` WHERE `player_id` = 3526 ORDER BY `time` LIMIT 1
running in Thread 4 (database async tasks thread) and:
Code:
INSERT INTO `player_storage` (`player_id`, `key`, `value`) VALUES (3526,990,2),(3526,991,12794),(3526,992,1641789078),(3526,993,130),(3526,994,109),(3526,2560,1),(3526,2561,1),(3526,2569,1),(3526,3550"...
running in Thread 2 (dispatcher thread).
It looks like your Database C++ class is not thread-safe. Is it same instance of Database? Is there 1 connection to MySQL or 2 [1 for each thread]?

Using single Database class with single MySQL connection by 2 threads is well known bug that make server crash.
In all old servers there was check in database, if IP is banned in main thread (network input) which make it randomly crash (rarely).
 
So yea probably it crashes because of this function in playerdeath.lua
Lua:
    local limit = deathRecords - maxDeathRecords
    if limit > 0 then
        db.asyncQuery("DELETE FROM `player_deaths` WHERE `player_id` = " .. playerGuid .. " ORDER BY `time` LIMIT " .. limit)
    end
Line #19 of the stack trace:
SQL:
DELETE FROM `player_deaths` WHERE `player_id` = 3526 ORDER BY `time` LIMIT 1
It looks like your MySQL version does not support the DELETE LIMIT statement.

Consider changing the query in playerdeath.lua to:
Lua:
if limit > 0 then
    db.asyncQuery("DELETE FROM `player_deaths` WHERE `player_id` = player_id AND `killed_by` = killed_by AND `mostdamage_by` = mostdamage_by IN (SELECT `player_id`, `killed_by`, `mostdamage_by` FROM `player_deaths` WHERE `player_id` = " .. playerGuid .. " ORDER BY `time` LIMIT " .. limit .. ")")
end
(!! Disclaimer: untested and, moreover, my SQL knowledge is pretty rusty)

Alternatively, consider upgrading your MySQL server and/or your MySQL driver to a version that supports the DELETE LIMIT statement.
Kinda scared to test it but i will :D
You got:
Code:
DELETE FROM `player_deaths` WHERE `player_id` = 3526 ORDER BY `time` LIMIT 1
running in Thread 4 (database async tasks thread) and:
Code:
INSERT INTO `player_storage` (`player_id`, `key`, `value`) VALUES (3526,990,2),(3526,991,12794),(3526,992,1641789078),(3526,993,130),(3526,994,109),(3526,2560,1),(3526,2561,1),(3526,2569,1),(3526,3550"...
running in Thread 2 (dispatcher thread).
It looks like your Database C++ class is not thread-safe. Is it same instance of Database? Is there 1 connection to MySQL or 2 [1 for each thread]?

Using single Database class with single MySQL connection by 2 threads is well known bug that make server crash.
In all old servers there was check in database, if IP is banned in main thread (network input) which make it randomly crash (rarely).
Yea i think im using 1 connection
 
So yea probably it crashes because of this function in playerdeath.lua
It's not exactly because of playerdeath.lua. Engine should be thread-safe and any call to MySQL should not finish in crash.
There are probably other asyncQuery in data folder and any of them may crash your server.
 
It's not exactly because of playerdeath.lua. Engine should be thread-safe and any call to MySQL should not finish in crash.
There are probably other asyncQuery in data folder and any of them may crash your server.
This makes a lot more sense indeed. I jumped early into conclusions. I saw that DELETE LIMIT and at first I was like "What? You can ORDER BY a DELETE statement?" ---again, my SQL knowledge is so rusty at this point--- And then I started to search online and saw that it was implemented later in MySQL's version 8.0 etc. etc. and so I assumed he may be running an older version of the database engine. But yeah, looking at the stack trace in detail, and taking into account what you just pointed out, your answer is probably right.
 
Last edited:
Back
Top