Demo Video

This video demonstrates the 2 Phase Commit Protocol.

Project Overview: Two-Phase Commit Protocol in Rust

This project implements a Two-Phase Commit (2PC) simulation using Rust. The implementation features three classes of interacting agents: client threads that submit requests, a coordinator thread that handles the 2PC protocol, and participant threads that execute operations. These threads communicate via Rust's crossbeam channels, with participants and coordinator writing to separate log files to document their actions.

Implementation Challenges:

Architecture & Component Interaction

The system consists of three primary components that interact through message passing:

System Components:

Control Flow:

Each component operates as a state machine with distinct states:

Implementation Details

Communication Mechanism:

Failure Handling:

Results & Verification

Verification Output:

                    omagr@parcheesi:~/concurrency/lab4$ ./target/debug/concurrency-2pc -s 0.95 -c 4 -p 4 -r 4 -m check -v 0
                    participant_0 OK: C:13 == 13(C-global), A:3 <= 3(A-global)
                    participant_1 OK: C:13 == 13(C-global), A:3 <= 3(A-global)
                    participant_3 OK: C:13 == 13(C-global), A:3 <= 3(A-global)
                    participant_2 OK: C:13 == 13(C-global), A:3 <= 3(A-global)

                

Coordinator Recovery (Extra Credit)

The extra credit implementation supports coordinator failure through:

                Simulate coordinator crash
                ./target/debug/concurrency-2pc -F 0.1 -c 3 -p 3 -r 3 -m run -v5

                Run recovery
                ./target/debug/concurrency-2pc -R -c 3 -p 3 -r 3 -m run -v5
                

Key Learnings

This project successfully implemented a robust Two-Phase Commit protocol in Rust, handling various failure scenarios while leveraging Rust's unique features for concurrency and safety.