Join our Newsletter — 33% off our NHI Course
Home› Glossary› Cyber Security› Database Deadlock
Cyber Security

Database Deadlock

← Back to Glossary
By NHI Mgmt Group Updated November 25, 2026 Domain: Cyber Security

A database deadlock is a situation where two or more transactions each hold locks the others need, so none can continue. The database detects the circular wait and aborts one transaction, or requires an application retry, to release the locks and let the remaining work finish.

How Database Deadlock Happens

A deadlock is a circular waiting pattern, not a simple slowdown. One transaction may hold a row lock while waiting for another lock, while a second transaction holds the second lock and waits for the first. Because each transaction is now blocking progress for the other, the database must detect the cycle and break it.

Deadlocks are usually a concurrency problem in application design, transaction ordering, or lock scope. They are not evidence that the database is “broken”; they are a predictable outcome when multiple sessions touch shared rows or tables in incompatible orders.

Why Deadlocks Matter in Production Systems

Deadlocks matter because they interrupt work that might otherwise succeed and they can surface under load, during peak concurrency, or after seemingly harmless code changes. When the database aborts one transaction, the application must retry cleanly or risk partial user actions, failed writes, and inconsistent workflows.

In practice, deadlocks often reveal broader contention patterns, such as long transactions, hot rows, or access paths that concentrate many updates on the same objects. The operational issue is rarely the single aborted transaction on its own, but the fact that repeated deadlocks can erode throughput and increase error rates.

Common Causes and Conditions

The most common trigger is inconsistent lock ordering. If one code path updates table A then table B, while another updates B then A, the two transactions can wait on each other indefinitely. Similar patterns arise with range locks, index changes, foreign key checks, or transactions that stay open longer than necessary.

Contention is more likely when transactions mix reads and writes, touch many rows, or hold locks while waiting on external work. The more state a transaction tries to preserve before commit, the larger the chance that another concurrent session will need one of the same resources.

How to Reduce and Recover From Deadlocks

The safest response is to keep transactions short, access shared objects in a consistent order, and make application retry logic explicit for deadlock errors. When retries are expected, they should be limited, observable, and safe to repeat so the aborted unit of work can complete without side effects.

Where retry alone is not enough, teams should reduce lock duration, break large writes into smaller units, and review whether the transaction scope is broader than the business action requires. Clear monitoring helps distinguish an occasional, acceptable deadlock from a recurring design flaw that needs refactoring.

Risk and Threat Considerations

Deadlocks create a reliability and availability risk when they occur frequently enough to stall throughput, trigger retries, or cause user-visible failures. In high-concurrency systems, they can become a denial-of-service style pressure point even without any malicious actor, simply because the same contested resources keep getting locked in incompatible orders.

Failure mechanism: Circular lock dependency prevents forward progress until the database aborts one transaction, and repeated aborts can amplify latency, retry storms, and transaction rollback overhead.

Impact: Poorly controlled deadlocks can delay commits, increase failed requests, and expose design weaknesses in transaction boundaries, lock ordering, and application retry handling.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

NIST SP 800-53 Rev 5 and CIS Controls v8 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
NIST SP 800-53 Rev 5SC-5 — Denial of Service ProtectionDeadlocks can create resource contention and service stalls.
CM-2 — Baseline ConfigurationDeadlock behavior is strongly influenced by schema, isolation, and transaction configuration.
Recommendation — Reduce lock contention and bound retry behavior to limit service disruption from deadlock-heavy workloads. Baseline database transaction settings and access patterns so concurrency behavior stays predictable.
CIS Controls v8CIS-4 — Secure Configuration of Enterprise Assets and SoftwareDatabase lock contention is often worsened by insecure or inconsistent configuration choices.
CIS-8 — Audit Log ManagementDeadlock events and retries are operational signals that should be logged and reviewed.
Recommendation — Harden database and application configuration to avoid concurrency settings that increase deadlock frequency. Log deadlock events and retry outcomes so recurring contention can be investigated and remediated.

Practitioner Guidance

What to watch for: Treat recurring deadlock errors as a signal to inspect transaction design, not just to increase retry counts. The useful question is whether the workload has a stable lock order and whether a transaction is holding locks longer than the business action truly needs.

Governance implication: Database deadlock handling should be owned jointly by application and platform teams, because the fix often sits in code path ordering, schema access patterns, or transaction scope rather than in the database engine alone.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on November 25, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org