September 25, 2025: PostgreSQL 18 Released!
DocumentationPostgreSQL devel (2025年10月03日 01:00:26 - git commit 25a30bbd423)
Supported Versions: Current (18) / 17 / 16
Development Versions: devel
This documentation is for an unsupported version of PostgreSQL.
You may want to view the same page for the current version, or one of the other supported versions listed above instead.
67.4. Two-Phase Transactions
Prev Up Chapter 67. Transaction Processing Home Next

67.4. Two-Phase Transactions #

PostgreSQL supports a two-phase commit (2PC) protocol that allows multiple distributed systems to work together in a transactional manner. The commands are PREPARE TRANSACTION, COMMIT PREPARED and ROLLBACK PREPARED. Two-phase transactions are intended for use by external transaction management systems. PostgreSQL follows the features and model proposed by the X/Open XA standard, but does not implement some less often used aspects.

When the user executes PREPARE TRANSACTION, the only possible next commands are COMMIT PREPARED or ROLLBACK PREPARED. In general, this prepared state is intended to be of very short duration, but external availability issues might mean transactions stay in this state for an extended interval. Short-lived prepared transactions are stored only in shared memory and WAL. Transactions that span checkpoints are recorded in the pg_twophase directory. Transactions that are currently prepared can be inspected using pg_prepared_xacts.


Prev Up Next
67.3. Subtransactions Home Chapter 68. System Catalog Declarations and Initial Contents

AltStyle によって変換されたページ (->オリジナル) /