How cmiyai/3phasecommit works
This repository implements three-phase commit for transactions spanning participant servers. A caller stages reads and writes on the relevant servers, then asks the coordinator to finish the transaction; the coordinator gathers votes, advances participants through pre-commit and commit, or aborts, and reports commit status and read values. Participants hold transaction state and key-value data. Coordinator recovery queries participant states and resumes or rolls back incomplete work. The repository includes a simulated RPC transport and Gob wrapper; config.go is tester support, not part of the runtime map. Relationships for protocol phases are documented in the README; source excerpts show coordinator RPC calls and participant handlers.
Main entry points: coordinator.go Coordinator · server.go Participant handlers · labrpc.go RPC network · labgob.go Gob codec
Components 10
Coordination
- Coordinator
coordinator.go - Coordinator recovery
coordinator.go - Transaction result
coordinator.go
Participants
- Participant handlers
server.go - Transaction state
server.go - Key-value store
server.go
RPC transport
- RPC network
labrpc/labrpc.go - RPC dispatch
labrpc/labrpc.go
RPC encoding
- Gob codec
labgob/labgob.go
Other components
- Transaction caller
Connections 14
- Transaction caller → Participant handlers: stages operations
server.go - Transaction caller → Coordinator: starts transaction
coordinator.go - Coordinator → Participant handlers: prepare, pre-commit, commit, abort, query
coordinator.go - Coordinator → Coordinator recovery: recovers on restart
coordinator.go - Coordinator recovery → Participant handlers: queries state
coordinator.go - Coordinator recovery → Coordinator: restarts protocol
coordinator.go - Coordinator → Transaction result: reports outcome
coordinator.go - Participant handlers → Transaction state: updates state
server.go - Participant handlers → Key-value store: reads and writes
server.go - Coordinator → RPC network: sends RPCs
coordinator.go - RPC network → RPC dispatch: dispatches requests
labrpc/labrpc.go - RPC dispatch → Participant handlers: invokes handlers
labrpc/labrpc.go - RPC network → Gob codec: encodes RPC data
labrpc/labrpc.go - Transaction caller → Transaction result: receives result
coordinator.go