Distributed Transaction (distributed_transaction)
Supports normal transactions and force_commit. In normal mode, the initiator prepares participators, asks the
coordinator to record the global decision, then notifies participators to execute and acknowledge local work.
force_commit executes during prepare without creating a coordinator record.
Location: src/component/distributed_transaction/ (see the README in that directory).
Quick Start
- Enable
dtcoordsvrand prepare Redis; configure transaction timeout, recovery, and cleanup in its chart. - Add
distributed-transaction-sdktoUSE_COMPONENTS; usesdk/transaction_client_handle.h,transaction_participator_handle.h, andrpc/transaction/transaction_api.h. - Implement participant callbacks using the component README's contract, prepare participants, resource keys, and transaction data, then submit through the client handle. Persist business data consistently with participant snapshots.
- Verify a normal commit and rejection after a prepare failure. Local actions/recovery callbacks must be idempotent. Start with normal transaction mode and follow the decision/recovery rules below.
Customization and Design
Composition
| Part | Location | Description |
|---|---|---|
dtcoordsvr | dtcoordsvr/ | Coordinator service: transaction_manager + a set of task actions |
| SDK | sdk/ | transaction_client_handle (initiator), transaction_participator_handle (participator), transaction_api |
| Protocol | protocol/ | distributed_transaction.proto, dtcoordsvr_config.proto |
Coordinator RPC (task action)
create / commit / reject / query / remove / commit_participator / reject_participator.
Flow
When the global terminal state is unconfirmed, the client performs bounded queries. Partial replica responses from a failed call cannot decide notification direction. Later local or delivery failures cannot reverse a confirmed decision.
See Distributed Transaction Design for conflicts, replication, recovery, callback states, and runtime contracts. Also follow the component README for callbacks and parameters.