DELAPARRA
Index
Color
NL
Category: Error types

DeadlockError

Explained by Updated

What is DeadlockError?

DeadlockError: Two or more threads/processes are each waiting for a resource the other holds — none of them can ever proceed. A deadlock error tells you the system detected a deadlock and stopped one of the parties. In MySQL it reads Deadlock found when trying to get lock; try restarting transaction. PostgreSQL reports deadlock detected.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about DeadlockError

How is DeadlockError used in practice?

The database chooses a victim transaction, rolls it back and lets the others continue. Your code receives the error and the work in that transaction is undone.

What should you keep in mind with DeadlockError?

Occasional deadlocks under heavy load are normal, and the right response is to retry the transaction. Laravel's DB::transaction() accepts a number of attempts for exactly this reason. Frequent deadlocks point to a design problem: transactions that run too long, rows updated in different orders by different code paths, or missing indexes that make the database lock more rows than needed. The database's deadlock log shows which queries collided.

At a glance

CategoryError types
Explained by
Updated

More Error types terms

All terms starting with D

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.