๐ŸŽ New User? Get 20% off your first purchase with code NEWUSER20 ยท โšก Instant download ยท ๐Ÿ”’ Secure checkout 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

Soft Delete
A pattern where records are marked as deleted with a flag or timestamp rather than being physically removed from the database.
Database Index Types
Different index structures (B-tree, Hash, GIN, GiST, BRIN) optimized for various query patterns and data types.
Elastic Search
A distributed search and analytics engine built on Apache Lucene, optimized for full-text search and log analysis.
CTE (Common Table Expression)
A temporary named result set defined within a SQL statement using the WITH clause, improving query readability and enabling recursion.
NoSQL
A category of databases that store data in non-tabular formats, optimized for specific data models and access patterns.
Redis
An open-source, in-memory data store used as a database, cache, message broker, and queue with sub-millisecond response times.
View All Databases Terms โ†’