Cognitive Scaffold

Preparing your thinking workspace

arrow_back_ios_new
MENTAL MODEL · M6277

Pessimistic Locking

Pessimistic Locking
TechnicalHigh supportSoftware Engineering
Included
account_tree

Updated 2026-07-28

Loading revision record…

Summary

In relational database management systems, pessimistic concurrency control (also known as "pessimistic locking", abbreviated as "PCC") is a method of concurrency control. It prevents a transaction from modifying data in a way that affects other users. If a transaction's operation reads a row of data and applies a lock, other transactions cannot perform operations that conflict with that lock until the transaction releases it.

Definition

In relational database management systems, pessimistic concurrency control (also known as "pessimistic locking", abbreviated as "PCC") is a method of concurrency control. It prevents a transaction from modifying data in a way that affects other users. If a transaction's operation reads a row of data and applies a lock, other transactions cannot perform operations that conflict with that lock until the transaction releases it. Pessimistic concurrency control is mainly used in environments with intense data contention, and where the cost of protecting data with locks when concurrent conflicts occur is lower than the cost of rolling back transactions.

How to use

In relational database management systems, pessimistic concurrency control (also known as "pessimistic locking", abbreviated as "PCC") is a method of concurrency control. It prevents a transaction from modifying data in a way that affects other users. If a transaction's operation reads a row of data and applies a lock, other transactions cannot perform operations that conflict with that lock until the transaction releases it.

Mechanism

Concurrency control strategy: lock before modifying data, assuming conflicts 'will happen', preventing others from writing simultaneously. The mechanism is to trade serialization for consistency, at the cost of reduced concurrency.

Practice

In progress 0/1

Practice this model in one real situation:

Check to track your progress (stored locally)
Learning progress0%

Cases

  • High-consistency scenarios like bank deductions use pessimistic locking to prevent overselling.

Common pitfalls

  • Indiscriminately adding locks regardless of scenario leads to performance bottlenecks; long transactions holding locks cause blocking and deadlocks.
Sources

Source support: Explicit

References currently contain only Wikipedia links; primary sources still need review.

  • link
    zh.wikipedia.orghttps://zh.wikipedia.org/wiki/%E6%82%B2%E8%A7%82%E5%B9%B6%E5%8F%91%E6%8E%A7%E5%88%B6ZH · Explicit
    verified
account_treeGenealogyexpand_more

RELATED MODELS