🎁 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

Migration
A version-controlled change to a database schema that can be applied and reversed systematically.
EXPLAIN Plan
A database command that shows how the query planner will execute a SQL query, revealing join methods, scan types, and estimated costs.
Full-Text Search
A technique for searching natural language text in databases using word stemming, ranking, and relevance scoring.
Time-Series Database
A database optimized for storing and querying timestamped data points like metrics, sensor readings, and event logs.
Database Connection Pooling
A technique that maintains a cache of database connections for reuse, reducing the overhead of creating new connections.
NoSQL
A category of databases that store data in non-tabular formats, optimized for specific data models and access patterns.
View All Databases Terms →