Operation Types
Every RPC in Gitaly is annotated with anop_type that specifies its operation category:
ACCESSOR
Accessor RPCs are read-only operations that do not modify repository data. They have no side effects and can be safely load-balanced across multiple replica nodes. Characteristics:- Side-effect free
- Safe to run on any replica
- Can be load-balanced for read distribution
- Do not require transaction coordination
- Do not trigger replication
MUTATOR
Mutator RPCs modify repository data. These operations change the Git repository state and require special handling in high-availability setups. Characteristics:- Modifies repository data (refs, objects, config)
- Must be routed to the primary node
- Requires transaction coordination in Praefect
- Triggers replication to secondary nodes
- May invoke Git hooks for authorization
MAINTENANCE
Maintenance RPCs perform housekeeping operations that optimize repository storage but don’t affect the user-visible repository state. Characteristics:- Optimizes repository structure
- Safe to run asynchronously
- May take significant time/resources
- Does not change user-visible repository state
- Typically scheduled rather than user-initiated
Role in High Availability
RPC categories are essential for Gitaly Cluster (Praefect) to provide high availability:Accessor RPCs
- Routed to any healthy replica
- Enable read load distribution
- Improve performance and availability
- No replication coordination needed
Mutator RPCs
Praefect handles mutator RPCs with strong consistency guarantees:- Routing: Always sent to the primary node
- Transaction Creation: Praefect creates a transaction with all replicas as voters
- Execution: The RPC executes on all replica nodes in parallel
- Voting: Each replica votes on the changes (via reference-transaction hook)
- Quorum: Changes are applied only if quorum is reached (typically all nodes must agree)
- Replication: If any replica fails, replication jobs are scheduled
Maintenance RPCs
- May be routed to any node
- Do not require transaction coordination
- Typically scheduled independently on each replica
- Can be rate-limited to prevent resource exhaustion
Transaction Voting
For mutator RPCs, Praefect uses Git’s reference-transaction hook to ensure all replicas agree on changes: Voting ensures:- All replicas intend to make the same changes
- Changes are applied atomically across all nodes
- Consistency is maintained even with network partitions
Determining Operation Type
When adding new RPCs, use these guidelines:| Does the RPC… | Category |
|---|---|
| Only read data, no side effects? | ACCESSOR |
| Modify refs, objects, or config? | MUTATOR |
| Only optimize storage layout? | MAINTENANCE |
- No divergence → ACCESSOR or MAINTENANCE
- Divergence → MUTATOR
Proto Annotation
Every RPC must be annotated in the.proto file: