THE ORB
Starting the studio

Deadlock found / Lock wait timeout exceeded

Two things tried to save the same record at the same moment and the database cancelled one of them.

groupsAn occasional failed savecodeNeeds a developer

Do this first

Occasional ones are normal. If it happens constantly, a script is saving far too often.

bug_reportPaste your whole console instead

What it means

Two transactions each hold a row the other wants. MySQL kills one so the other can finish — the killed one is the error you are reading. A lock wait timeout is the milder cousin: nobody deadlocked, one query just waited too long for a lock and gave up.

Neither is corruption. The database did the right thing; the code has to handle it.

What causes it

Ordered by how often it is the answer.

  1. 1

    Two saves for the same player at once

    An autosave and a manual save racing on the same row.

  2. 2

    Rows locked in different orders

    One code path updates the user then the vehicle, another the vehicle then the user. That is the textbook deadlock.

  3. 3

    A long transaction holding locks

    A transaction opened, then something slow done inside it, then committed.

  4. 4

    A mass UPDATE at peak

    A payday or a wipe touching every row while players are also being saved.

  5. 5

    Missing indexes widening the lock

    Without an index, an UPDATE locks far more rows than it needs to.

How to tell which one is yours

SHOW ENGINE INNODB STATUS;

The LATEST DETECTED DEADLOCK section names both transactions and both statements, which is usually the entire diagnosis.

Where to look

The two statements InnoDB names, and whether they touch the same tables in different orders.

How to fix it

Lock in a consistent order everywhere, keep transactions short, index what you filter on, and retry once on a deadlock rather than failing the operation:

CREATE INDEX idx_users_identifier ON users (identifier);

A deadlock is a retryable error by design — the second attempt normally succeeds because the conflicting transaction has finished by then.

Still stuck on your own code?

This page is what this error usually means. Paste your console into Server Fixer and it will rank everything in it and tell you what to do first, and if you would rather not touch it, ORBIE can repair the script and hand the resource back ready to drop in.

bug_reportOpen Server Fixer

Errors that travel with this one