Pessimistic concurrency control is a conflict prevention strategy that uses locks to guarantee exclusive access to shared resources, preventing data inconsistencies by assuming conflicts are likely and blocking concurrent access upfront.
In this model, an agent (or transaction) that needs to read or modify a data item must first acquire a lock. The type of lock determines what other agents can do:
- Exclusive (Write) Lock: Grants the holder exclusive read/write access; no other agent can acquire any lock on the same resource.
- Shared (Read) Lock: Allows multiple agents to read a resource concurrently, but prevents any agent from acquiring an exclusive lock for writing.
This approach is 'pessimistic' because it operates on the assumption that if multiple agents are allowed to access a resource simultaneously, they will likely create a conflict (a 'write-write' or 'read-write' hazard). By serializing access via locks, it ensures serializability—the gold standard for transaction isolation—making the outcome equivalent to executing all transactions one after another. It is commonly implemented in traditional relational database management systems (RDBMS) and is crucial for maintaining ACID properties, particularly Isolation.