fix: guarantee sequential consistency across recovery - #99
Open
Tech-Matt wants to merge 38 commits into
Open
Conversation
…he system Related to #59
…saction
* Continued the intrgration of the `UpdateTransaction` with the system,
* Fixed initialization of `HeartbeatTransaction`'s `TransactionId` to use the proper `Replica` method
* Created the `TestUpdateTransaction` class to test the `UpdateTransaction` functionality, this test:
- a basic write operation issued to a non-coordinator replica
- a basic write operation issued to a non-coordinator replica that is crashed, expecting a timeout response
- a basic write operation issued to a non-coordinator replica followed by a crash of the coordinator replica, expecting a timeout response
* Corrected the `transaction_Write.mmd` chart to be compliant to the implementation
Fixes #55, Related to #59, #60, #61
I've fixed the destination provided when the `UpdateTransaction` is issued on the replicas that dosn't initiated the transaction. Corrected also the test to ensure this behaviour
Reordered the replica cases to check first if the replica is the coordinator or not.
…RDINATOR_BEAT_INTERVAL` I changed the original function to use a parameter for the heartbeat interval instead the class constant. This is to speedup tests, infact having an interval of 1s could result in really long tests timings
Before, if a `WriteTransaction` is issued on the coord directly would fail due to non complete termination protocol. Now is fixed Fixes #89
- Now each replica contains a `Map<EpochPair, UpdateTransactio>` where the updates are stored. - Each `Replica` epochPair is updated after the each update
…action diagrams inside the `charts/transactions` folder
Introduce immutable election candidates ordered by EpochPair, with replica ID as the deterministic tie-breaker. Add ring-navigation rules for wraparound, skipped replicas, and the no-available-replica case. These pure rules establish predictable election behavior before adding Akka messages, timeouts, and FSM transitions.
Add deterministic candidate comparison and ring navigation with wraparound and failed-replica skipping. Introduce immutable ElectionMsg, ElectionAckMsg, and local ElectionAckTimeoutMsg objects. Add regression coverage and update the election sequence diagram to match the simplified message contract.
Implement ElectionTransaction with immutable election messages, candidate comparison, deterministic replica-ID tie-breaking, ring navigation, ACK timeouts, failed-replica skipping, and coordinator selection. Integrate election startup with heartbeat failure detection and Replica message dispatch. Add coordinator callbacks, synchronization messages carrying the authoritative positions snapshot, epoch advancement, and heartbeat restart after election completion. Extend regression coverage for candidate ordering, ring navigation, message immutability, ACK metadata, timeout metadata, and synchronization snapshots. Update the election sequence diagram to document the implemented protocol flow.
Reserve a separate transaction-ID namespace for elections so delayed ACKs and timeouts cannot be routed to heartbeat transactions. Schedule election startup according to ring distance, arbitrate concurrent election attempts by initiator ID, and reject losing election transactions. Increase ACK timeout coverage to include token forwarding and the return acknowledgement, preventing healthy replicas from being discarded prematurely. Update the election diagrams to document the arbitration and round-trip timeout behavior.
Reject malformed or stale election and synchronization messages before they can create invalid local transactions or poison a recovery term. Track the election transaction through synchronizing and completion, align the diagrams with forward-before-ACK ordering, and add regression coverage for forged, malformed, and invalid synchronization traffic.
…ener integration
There was no call to `replica.setPosition(int, int)`
…sg and improved test cases for crash scenarios
…equential-consistency
…/sequential-consistency # Conflicts: # src/main/java/it/unitn/ds/Replica.java
…o fix/sequential-consistency # Conflicts: # src/main/java/it/unitn/ds/Replica.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
maindid not guarantee the sequential consistency required byspecs/ds1_project_2026_v1.pdf: reads were unimplemented there, the update and election protocols were still separate, update identities were not stable, and coordinator recovery could fork or lose the committed prefix.This PR:
14b243b), Feat: UpdateTransaction #86 (73052d2), and Implement ring-based ElectionTransaction FSM and coordinator recovery #97 (d1222a2);EpochPairvalues;UPDATE -> ACK -> WRITEOK -> apply -> history -> WriteFinish;UPDATE, and separates heartbeat, ordinary, and election transaction-ID namespaces;WRITEOKrecovery tests;Correctness argument
Clientserializes each client's operations through one current transaction and a FIFO queue.EpochPair, synchronizes one common prefix, and only then continues in a higher epoch.The report gives the complete proof and explicitly separates this safety result from assumptions about bounded delay, strict-majority availability, and reasonable client timeouts.
Validation
Run with an isolated Gradle home because the machine's default Gradle home could not load its native platform library:
Results:
BUILD SUCCESSFULwith 0 errors, 42 warnings, 2 informational findings, 2 duplication findings, and 0 formatting findings;The non-error static-analysis findings are principally in the integrated election implementation and do not block the build. Reports are generated under
build/reports/.Integration note
Because
maindid not yet contain the read, update, or election state machines needed to establish this end-to-end property, this PR includes the live work from #83, #86, and #97. Those PRs should not be merged independently without reconciling their history with this branch.