Having issues with my custom durability system where item metadata gets corrupted when multiple players stack/unstack the same item quickly. The durability values show as negatives in the UI and sometimes items end up with duplicated metadata like {"durability": {"durability": 45}} instead of {"durability": 87}.
MySQL logs show 'Deadlock found when trying to get lock' during peak times and I'm seeing malformed JSON in the database. Using QBCore with custom durability integrated into qb-inventory, oxmysql 2.7.3, and OneSync Infinity.
Here's my current stack event handler:
RegisterServerEvent('qb-inventory:server:StackItems', function(fromSlot, toSlot, amount)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local fromItem = Player.PlayerData.items[fromSlot]
local toItem = Player.PlayerData.items[toSlot]
-- Direct database update without transaction protection
if fromItem.name == toItem.name then
MySQL.update('UPDATE player_items SET amount = ?, metadata = ? WHERE id = ?', {
fromItem.amount + toItem.amount,
json.encode(fromItem.info), -- Vulnerable to concurrent modifications
toItem.id
})
end
end)Anyone dealt with concurrent metadata updates causing corruption? The inventory sync fails between client/server during these events and it's affecting gameplay heavily.
NexusZero · 03/09/2026
Sign in to reply.