Two-phase commit (2PC) and XA (eXtended Architecture) are two important concepts in database transactions and distributed systems. In distributed transaction processing, a commit operation finalizes a transaction and makes it visible to other participants. In an extended two-phase commit protocol, the commit action is split into two phases: Prepare and Commit. The first phase is called prepare because the participant prepares to commit by checking some pre-conditions. The main advantage of a 2PC protocol is that it enables automatic recovery from failures during transactions. In this article, we will explain the two-phase commit protocol and XA in detail and discuss their use cases and limitations.