Skip to content

Frank/raft phase8 - #5

Open
Overcomplicated12 wants to merge 33 commits into
frank/raft-rustdslfrom
frank/raft-phase8
Open

Frank/raft phase8#5
Overcomplicated12 wants to merge 33 commits into
frank/raft-rustdslfrom
frank/raft-phase8

Conversation

@Overcomplicated12

@Overcomplicated12 Overcomplicated12 commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Raft Phase 8: Transport, Dispatcher, Storage, and TestCluster Decoupling

Summary

This PR completes the Phase 8 Raft decoupling work on top of d76e88d9.

It introduces explicit boundaries for outbound transport, inbound dispatch, storage, and test-cluster lifecycle management. It also upgrades TestCluster to run real RaftServer instances under controlled transport faults and restart scenarios.

What Changed

Outbound Transport Decoupling

  • Route all RaftServer outbound RPCs through TransportProxy.
  • Migrate the following outbound paths:
    • Vote
    • AppendEntries
    • Durable AppendEntries
    • InstallSnapshot
    • TimeoutNow
  • Remove direct outbound use of commo() from RaftServer.
  • Remove legacy quorum and fanout machinery, including:
    • RaftVoteQuorumEvent
    • SendAppendEntriesResults

Dispatcher Boundary

  • Introduce RaftServerDispatcher.
  • Adapt RaftServer::On* handlers to the DispatcherFacade / DispatcherProxy boundary.
  • Route RaftServiceImpl through the dispatcher instead of directly owning Raft server behavior.
  • Add lifecycle and default-reply handling for disconnected or absent servers.

Storage Decoupling

  • Move LogStorage access behind narrow facade and proxy boundaries.
  • Move SnapshotManager access behind narrow facade and proxy boundaries.
  • Preserve existing storage behavior while removing service and test-cluster coupling to concrete storage implementations.

TestCluster and Standalone Raft Lab

  • Run real RaftServer instances through TestCluster.
  • Port RaftTestConfig into the cluster.
  • Update raft_lab_standalone to execute the full Raft lab through TestCluster.
  • Add coverage for:
    • Directed transport faults
    • Partition and reconnection recovery
    • Node kill and restart
    • Retained storage
    • PollThread lifecycle behavior

Lifetime and Ownership

  • Clean up server and worker lifetime leaks.
  • Tighten ownership edges exposed by real-server cluster testing.
  • Ensure workers and PollThread instances terminate before server destruction.
  • Prevent background work from accessing destroyed RaftServer objects.

Rust-DSL and Clang 22 Compatibility

  • Preserve valid hashes for generated Rust-DSL blocks.
  • Use rusty::Vec for:
    • Internal snapshot payload buffers
    • Snapshot staging buffers
    • Channel fault state
  • Fix header-generated ODR issues.
  • Fix Clang 22 CMake and import std compatibility.
  • Decouple test_rpc_log_storage from txlog_core and RocksDB.
  • Lazily allocate the 64 KiB TCP receive scratch buffer.

Validation

Rust-DSL Validation

All generated Raft Rust-DSL blocks pass:

inline-rust --check

Coverage includes 26 Raft source files.

Focused Clang 22 Tests

The following focused tests pass:

test_raft_channel_transport
test_raft_memory_snapshot_manager

Phase 8 Coverage

This PR adds or updates focused coverage for:

  • Dispatcher lifecycle behavior
  • Default replies for missing or disconnected servers
  • Transport fault recovery
  • Real-server TestCluster execution
  • Log-storage and snapshot-storage proxies
  • Node restart with retained storage
  • Worker and PollThread ownership

Notes

This branch also includes the Rust-DSL memory-footprint work merged from frank/raft-rustdsl.

That work:

  • Removes the unnecessary RocksDB dependency from the lightweight log-storage test.
  • Replaces the fixed 64 KiB thread-local TCP receive scratch object with lazy per-thread allocation.
  • Preserves the existing C++ systems boundaries while migrating suitable low-risk components to the Rust-DSL path.

…te SendAppendEntriesResults + RaftVoteQuorumEvent
# Conflicts:
#	CMakeLists.txt
#	src/deptran/raft/channel_transport.hpp
#	src/deptran/raft/server.cc
# Conflicts:
#	src/deptran/raft/channel_transport.hpp
#	src/deptran/raft/commo.h
#	src/deptran/raft/quorum.hpp
#	src/deptran/raft/server.cc
#	src/deptran/raft/service.cc
# Conflicts:
#	src/deptran/raft/quorum.hpp
#	src/deptran/raft/raft_node.hpp
#	src/deptran/raft/test_cluster.hpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant