OceanBase Database implements the native two-phase commit protocol to ensure the atomicity of distributed transactions.
The two-phase commit protocol involves two roles: coordinator and participant. The coordinator advances the entire protocol to facilitate consensus between participants. Participants complete operations like prepare, commit, and rollback as requested by the coordinator.
Commit process of a distributed transaction
The following figure shows the two-phase commit process for traditional databases and OceanBase Database.

Prepare phase
The coordinator sends a prepare request to each participant.
After receiving the prepare request, each participant determines whether a transaction can be committed. If the transaction can be committed, the participant persists the prepare logs and returns a prepare success response to the coordinator. If the transaction cannot be committed, the participant returns a prepare failure response to the coordinator.
Commit phase
After receiving prepare ACK signals from all participants, the coordinator enters the COMMIT state and returns a commit success response to the user. Then, the coordinator sends a commit request to each participant.
After receiving the commit request, each participant releases resources, unlocks rows, and then submits commit logs. After the logs are persisted, the participant returns the commit ok message to the coordinator, releases the transaction context, and then exits.