A distributed banking system implementing two-phase commit (2PC) protocol and timestamp ordering for managing concurrent transactions across multiple server branches.
This system implements a distributed banking application where multiple server branches coordinate to handle client transactions consistently. It features:
- Two-Phase Commit (2PC) protocol for distributed transaction management
- Timestamp ordering for concurrent transaction handling
- Support for multiple concurrent clients
- Fault tolerance and transaction rollback capabilities
The system consists of two main components:
- Implements branch coordination and transaction processing
- Handles client connections and inter-server communication
- Maintains account balances and transaction states
- Supports deposit, withdraw, and balance query operations
- Uses timestamp ordering for serializable transaction execution
- Connects to a randomly selected coordinator server
- Sends transaction requests in a defined format
- Handles responses and transaction status updates
- Supports interactive command input
DEPOSIT <branch>.<account> <amount>- Add funds to an accountWITHDRAW <branch>.<account> <amount>- Remove funds from an accountBALANCE <branch>.<account>- Query account balanceCOMMIT- Commit a transactionABORT- Abort and rollback a transaction
- Start the server branches:
go run server/server.go <branch-name> <config-file>- Start a client:
go run client/client.go <client-id> <config-file>- Begin a transaction by typing "BEGIN"
- Enter transaction commands and end with "COMMIT" or "ABORT"
The system requires a config file specifying server branch details:
<branch> <hostname> <port>
A localhost 1111
B localhost 2222
C localhost 3333
The system handles various error conditions:
- Network failures
- Invalid transactions
- Concurrent access conflicts
- Account not found
- Insufficient funds