summaryrefslogtreecommitdiff
path: root/core/replica.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-23 04:21:13 -0300
committerGabriel Schneider <[email protected]>2026-11-23 07:28:22 -0300
commit396247178d20678a36e9e1782c2a457eeb1916de (patch)
tree80d9b7d21cdcd64b2b246eae92c6f817f3a882e8 /core/replica.zig
parent3a0acb503613a672c3d84f685031ab5e65c10ff6 (diff)
downloadpardes-396247178d20678a36e9e1782c2a457eeb1916de.tar.gz
pardes-396247178d20678a36e9e1782c2a457eeb1916de.zip
link: a far client that falls behind dials again, as before round 1 (the coordinator's ruling P63a): `Link.backHere` says no for a link that crosses machines (`Link.far`, set by runtime/client.zig from its `Have`) and fell behind `behind_max_ms`, so that client says its goodbye, shuts its link and dials again through the daemon, a new connection that drops what the old one holds for it; every other way back (a divergence, a near lag, a cut, a refused load's ask) stays on the link; marked in the code as the second road it is, with what replaces it (bounded flight: the session never more than a window past what its client has taken); the failing row first: test/daemon.py `--far` on ReleaseSafe 6 of 7 on round 1's tree (`far_flood`: over its own link the far client read through all the relay held for it, agreeing 49-68 s after `yes` against 22.7 s by a dial); `far_flood` now asserts the far client behind took ANOTHER connection; the lag test asserts both roads (`backHere` near yes, far no) ; gated with the next change as its tree (g1, rnllpvzw fd3730201cb3): `--far` on ReleaseSafe 7 of 7, far_flood ANOTHER connection each time and agreed 22.3-26.0 s after `yes` ended (Debug 25.3 s), every other row as before: core-test 931/1095 (164 skipped), shell-test 1137/1140 (3 skipped), process-test 0 of 146 failed both ways, the soak x3 and --pair x3 clean, daemon.py every mode on both builds, the upgrades 12 of 12, frames 77/77 and 121 counts within 0.1% against tree6, the cross-builds
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/replica.zig')
-rw-r--r--core/replica.zig16
1 files changed, 16 insertions, 0 deletions
diff --git a/core/replica.zig b/core/replica.zig
index 448c428f..79abd977 100644
--- a/core/replica.zig
+++ b/core/replica.zig
@@ -3292,6 +3292,9 @@ pub const Link = struct {
fresh: bool = true,
/// How far behind it was as it let its link go (`rejoins` says so).
lagged: u64 = 0,
+ /// Its link crosses machines (a `Have`: ssh's forward, a relay): fallen
+ /// behind, it dials again (`backHere`).
+ far: bool = false,
/// A pair's first join, its own boot not confirmed yet: its inputs
/// kept here, not sent (`release`; client.zig `confirm`).
held: ?std.ArrayListUnmanaged(u8) = null,
@@ -3526,7 +3529,15 @@ pub const Link = struct {
/// a cut's keep the link, an Upgrade's and a Restore's end it, which the
/// join there finds): its goodbye and hello are said on it (`comeBack`).
/// One that is gone, or a last word, is not.
+ /// THE SECOND ROAD: a far client that fell behind dials again (a new
+ /// connection; the one it leaves is shut): over its own link it would
+ /// first read through all that link holds for it, which a relay or a
+ /// forward buffers without bound (test/daemon.py `far_flood`: 49-68 s
+ /// to agree after the flood against 22.7 s by a dial). Bounded flight
+ /// (the session never more than a window past what its client has
+ /// taken) replaces it, and this line goes.
pub fn backHere(c: *const Link) bool {
+ if (c.far and c.lagged != 0) return false;
return !c.gone and c.ended == null and !c.left and (c.r.diverged != null or c.lagged != 0 or c.refused != null);
}
@@ -6053,6 +6064,11 @@ test "a client whose session's units come more than two seconds later than its q
// core is behind on purpose, no divergence.
link.take(.{ .checked = digestOf(a) +% 1 });
try std.testing.expect(r.diverged == null);
+ // It comes back over its link; far, it dials again (`backHere`).
+ try std.testing.expect(link.backHere());
+ link.far = true;
+ try std.testing.expect(!link.backHere());
+ link.far = false;
try std.testing.expect(link.rejoins());
try std.testing.expectEqualStrings("joined again: 2.1 s behind", link.notice());
try std.testing.expect(!link.rejoins());