🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

Databases Advanced

What is Deadlock?

A situation where two or more transactions permanently block each other by each holding locks that the other needs.

A deadlock occurs when Transaction A locks Row 1 and waits for Row 2, while Transaction B locks Row 2 and waits for Row 1. Neither can proceed. Databases detect deadlocks and abort one transaction to break the cycle.

Prevention strategies include consistent lock ordering (always lock resources in the same order), keeping transactions short, using appropriate isolation levels, and using SELECT FOR UPDATE SKIP LOCKED for queue patterns.

Related Terms

Elastic Search
A distributed search and analytics engine built on Apache Lucene, optimized for full-text search and log analysis.
Replication
The process of copying and maintaining database data across multiple servers for redundancy, failover, and read scaling.
Upsert
A database operation that inserts a new row if it does not exist, or updates the existing row if it does.
Partitioning
A technique of dividing large database tables into smaller, more manageable segments while maintaining a single logical table.
Window Function
An SQL function that performs calculations across a set of rows related to the current row without collapsing the result set.
EXPLAIN ANALYZE
A PostgreSQL command that shows the execution plan of a query along with actual runtime statistics for performance tuning.
View All Databases Terms →