Two-Phase Locking
also called 2PL
The concurrency control protocol behind serializable isolation — acquire locks in a growing phase, release only in a shrinking phase, never interleaving the two.
Not to be confused with two-phase commit, which is about atomicity across resources. Two-phase locking is about isolation within one.
The rule: a transaction acquires all the locks it needs before releasing any. Once it releases the first, it may not acquire another. That discipline is what makes the resulting schedule equivalent to some serial order, which is the definition of serializable.
The costs are the reason most systems do not run at this level by default. Locks held to commit means reduced concurrency; conflicting transactions deadlock and one must be aborted and retried; and long-running transactions block everything they touch.
The modern alternative is serializable snapshot isolation — used by PostgreSQL's SERIALIZABLE level — which is optimistic: transactions proceed without blocking and are aborted at commit if a dangerous read-write dependency structure is detected. Better throughput under low contention, more aborted transactions under high contention, and the application must be prepared to retry.