Overview
This service is critical for Praefect’s strong consistency model. When a write operation affects Git references, all participating nodes vote on the transaction using this service. The transaction only succeeds if the voting reaches quorum according to the configured strategy.The RefTransaction service works in conjunction with Git’s reference-transaction hook to ensure atomic updates across multiple nodes.
VoteTransaction
Cast a vote in a distributed transaction for reference updates. This RPC is called during the Git reference-transaction hook to coordinate votes between primary and secondary Gitaly nodes. Each node computes a hash of the reference updates and votes with that hash.The repository where the transaction is occurring
Unique identifier of the transaction being voted on
Name of the Gitaly node casting the vote
SHA1 hash of all reference updates being applied in this transaction
The voting phase for this transactionPhases:
UNKNOWN_PHASE(0) - Unknown phase (deprecated, will become unsupported)PREPARED_PHASE(1) - Preparatory phase. Data is locked but not yet written to diskCOMMITTED_PHASE(2) - Committing phase. Data has been written to disk
Response
The outcome of the transaction voteStates:
COMMIT(0) - Transaction should be committedABORT(1) - Transaction should be rolled backSTOP(2) - Transaction voting should stop
Transaction Flow
The two-phase voting process (PREPARED and COMMITTED) ensures that all nodes agree on the changes before any node makes them permanent.
StopTransaction
Stop an ongoing transaction, typically used when an error occurs or the transaction is cancelled.The repository where the transaction is occurring
Unique identifier of the transaction to stop
Response
Empty response indicating the transaction has been stopped.Usage in High Availability
The RefTransaction service is automatically invoked by Git’s reference-transaction hook when Praefect is configured for strong consistency. You typically don’t call these RPCs directly unless implementing a custom Gitaly client.Reference Transaction Hook
Git calls the reference-transaction hook at three points during reference updates:- prepared - After locks acquired, before writing
- committed - After writing, before unlocking
- aborted - If the transaction fails
Voting Strategies
The transaction coordinator (Praefect) supports different voting strategies:- Strong consistency - All nodes must vote with matching hashes
- Majority wins - Primary + at least half of secondaries must agree
- Primary wins - Transaction succeeds if primary votes successfully