Running qb-banking v1.2.4 with oxmysql 2.9.7 and hitting a weird desync issue. When multiple players hit the same shared account within ~200ms of each other, the database ends up with the correct final balance but PlayerData.statebag.value shows stale data.
The MySQL logs show both transactions completed properly with the right final amount, but the statebag only reflects the first operation. This causes subsequent transactions to fail with "insufficient funds" even though the actual DB balance is correct.
Only way to fix is player reconnects or switches chars. Getting 'Statebag update collision' warnings in console when this happens.
RegisterNetEvent('qb-banking:server:DepositMoney', function(accountId, amount)
-- No locking mechanism
MySQL.update.await('UPDATE bank_accounts SET balance = balance + ? WHERE id = ?', {amount, accountId})
TriggerClientEvent('hud:client:OnMoneyChange', source, 'bank', amount, true)
-- Statebag update happens without verifying database consistency
Player(source).state:set('bank_balance', GetAccountBalance(accountId), true)
end)Memory usage creeps up with each incident from abandoned callbacks. Any ideas what's causing the statebag to not sync properly when multiple ops happen at once?
SilentKiller · 01/09/2026
Sign in to reply.