fix(distributed): 2PC atomicity, DISTTXN handler, sharding bugs, gossip timers

- disttxn: prepare failure rolls back already-prepared participants (C1)
- disttxn: commit failure rolls back committed participants (C2)
- server: DISTTXN handler uses real DistTxnManager (C3)
- server: DistTxnManager initialized in newServer() (H1)
- sharding: getShardRange returns -1 instead of 0 for out-of-range keys (M6)
- sharding: binary search in consistent hashing ring (M7)
- gossip: startHealthCheck() and startGossipRound() async loops
- 283 tests, 0 failures
This commit is contained in:
2026-05-07 14:13:17 +03:00
parent 32187099dd
commit d259c1a1fc
5 changed files with 101 additions and 51 deletions
+13
View File
@@ -2,6 +2,7 @@
import std/tables
import std/random
import std/monotimes
import std/asyncdispatch
type
NodeState* = enum
@@ -167,3 +168,15 @@ proc isMember*(gp: GossipProtocol, nodeId: string): bool =
proc getMember*(gp: GossipProtocol, nodeId: string): GossipNode =
gp.members.getOrDefault(nodeId, nil)
proc startHealthCheck*(gp: GossipProtocol, intervalMs: int = 1000) {.async.} =
while true:
await sleepAsync(intervalMs)
gp.checkHealth()
proc startGossipRound*(gp: GossipProtocol, intervalMs: int = 2000) {.async.} =
while true:
await sleepAsync(intervalMs)
let targets = gp.selectGossipTargets()
# In production: serialize createGossipMessage() and send to targets via UDP/TCP
discard targets