From f148c600d35cca72c9c2ad2bb03086b9a8587c71 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 22 Nov 2026 21:13:14 -0300 Subject: replica: a client no longer gives up its session while the session says it is upgrading: `redial` (core/replica.zig) counted the session's own refusal `upgrading` (Peers.refuseAll, from telling its clients until its exec, the dump written and fsynced between) as one of its 201 tries of 100 ms, so an Upgrade whose dump took over 20 s let every client go for good, each exiting "could not join again: the session is upgrading to another build of pardes" while its session came back (a release build alike: the bound is the client's); now that word is dialled again without counting, every other failure keeps the 20 s; with an experiment's 24 s sleep after refuseAll (a slow dump) the base failed 1 of 1 with the gate's words (both clients gone, `--ps` listing none, the session back at 24.2 s) and this passed the step 2 of 2 (both back at 24.2 s, with the session); not the cause of the gate's failures as kept (the session back in 0.3 s there): traced on one CPU the window is 33 ms; core-test 917/1074 (157 skipped), shell-test 1116/1119 (3 skipped) (load 3.4-4.1); left: a client of a session stuck inside its Upgrade keeps dialling, a TERM to it waiting as it waited up to 20 s before Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- core/replica.zig | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'core') diff --git a/core/replica.zig b/core/replica.zig index 71a8de71..01a532b5 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -2936,7 +2936,10 @@ fn sameBuild(gpa: Allocator, j: Joined, why: []u8) ?Joined { /// The session again, after a divergence or an upgrade: an upgrade's /// takes the time its exec and load take, and its daemon's, so it is -/// dialled every 100 ms for 20 s. Null, and why in `why`. +/// dialled every 100 ms for 20 s. Null, and why in `why`. The session's +/// own word that it is upgrading (`Peers.refuseAll`, until its exec) is +/// not a try: it is there, writing its dump for as long as that takes (a +/// 24 s write let every client go for good, 2026-11-22). /// `patient`: after an Upgrade's `refused` alone, while the session is /// away a moment; after a divergence a session that will not answer is /// gone, and the client says so at once (it froze 20 s, 2026-10-30). @@ -2944,7 +2947,7 @@ fn sameBuild(gpa: Allocator, j: Joined, why: []u8) ?Joined { /// none for a first join that met an Upgrade. fn redial(gpa: Allocator, path: []const u8, session: []const u8, why: *[600]u8, have: ?*Have, patient: bool, view: ?u8) ?Joined { var tries: u32 = 0; - while (true) : (tries += 1) { + while (true) { why.* = @splat(0); if (dial(gpa, path, session, why, have, view)) |j| return sameBuild(gpa, j, why); // Another build, or another protocol (the daemon moved with its @@ -2957,7 +2960,10 @@ fn redial(gpa: Allocator, path: []const u8, session: []const u8, why: *[600]u8, // Its daemon lists no such session: it is gone, not away a moment // (an Upgrade keeps it listed throughout). if (std.mem.startsWith(u8, words, "no session called ")) return null; - if (!patient or tries > 200) return null; + if (!std.mem.eql(u8, words, upgrading)) { + if (!patient or tries > 200) return null; + tries += 1; + } const ts: libc.timespec = .{ .sec = 0, .nsec = 100 * std.time.ns_per_ms }; _ = libc.nanosleep(&ts, null); } -- cgit v1.3 From 111e53418c72717cb1decf56767d2f79188cf9fc Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 22 Nov 2026 21:22:18 -0300 Subject: replica: a client of the old build that comes back at an Upgrade before the daemon has heard the session's new build no longer closes the view kept for it: the daemon judges a hello by the build its session last said (runtime/daemon.zig `hear`), so in that window it hands the old client to the new session, which welcomes it into its kept view (Peers.join, rejoinView); the client then finds another build (`sameBuild`) and said its bye without `again`, so the session closed that view: its exec'd self (client.zig `execAgain`) came back in a new view, its layout and pane lost, and one that never comes back left no view kept for its 30 s; now a rejoin's bye on another build says `again`: the view stays kept (views.away) for the build at its start path or until its bound; test/daemon.py --upgrade release to Debug on one CPU failed so 7 of 20 (5 at "the daemon lists the session": the join before it welcomed, the next refused "one is kept 30 s more"; 2 at "the second client of the build running drawn"), traced: `join view=3 ... as view 3` (the stale old-build client) then `open=101`; after (both builds with it) 0 of 20 there (18 of 20 whole: the other two the dump-load fault the first change keeps); core-test 917/1074, shell-test 1116/1119 Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- core/replica.zig | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'core') diff --git a/core/replica.zig b/core/replica.zig index 01a532b5..a2dd8e15 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -2828,7 +2828,7 @@ pub fn join(gpa: Allocator, j: *Joined, path: []const u8, session: []const u8, o sameBuild(gpa, (dial(gpa, path, session, why, have, null) orelse // Handed to the session as it upgraded, or cut by its exec with // its dump on the way: it is there again soon. - if (std.mem.eql(u8, std.mem.sliceTo(why, 0), upgrading) or cutListed(why, session, have != null)) redial(gpa, path, session, why, have, true, null) else null) orelse return null, why)) orelse return null; + if (std.mem.eql(u8, std.mem.sliceTo(why, 0), upgrading) or cutListed(why, session, have != null)) redial(gpa, path, session, why, have, true, null) else null) orelse return null, why, false)) orelse return null; defer { if (have) |h| h.store(gpa, j) else gpa.free(j.dump); j.dump = &.{}; @@ -2905,7 +2905,7 @@ fn ownBoot(gpa: Allocator, j: *Joined, fd: c_int, o: pardes.Options, why: *[600] pub fn confirmBoot(gpa: Allocator, j: *Joined, r: *Replica, o: pardes.Options, why: *[600]u8) ?*Replica { const t0 = nowNs(); const digest = j.digest; - j.* = sameBuild(gpa, joinOn(gpa, j.fd, null, why, null, null, digest) orelse return null, why) orelse return null; + j.* = sameBuild(gpa, joinOn(gpa, j.fd, null, why, null, null, digest) orelse return null, why, false) orelse return null; if (j.dump.len == 0) { r.id = j.client; r.view = j.view; @@ -2922,10 +2922,14 @@ pub fn confirmBoot(gpa: Allocator, j: *Joined, r: *Replica, o: pardes.Options, w /// `j`, when its session runs this build; else its link let go, and why in /// `why`: the daemon judged the hello by what the session last said, which -/// an upgrade under way may not have said yet. -fn sameBuild(gpa: Allocator, j: Joined, why: []u8) ?Joined { +/// an upgrade under way may not have said yet. `again`: it was a rejoin for +/// the view the session kept, which the welcome gave it: kept again for it +/// (its bye's `again`), for the build at its start path, exec'd, to come +/// back to (client.zig `execAgain`); closed, it came back in a new view, +/// its own lost (1 in 4 Upgrades on one CPU, 2026-11-22). +fn sameBuild(gpa: Allocator, j: Joined, why: []u8, again: bool) ?Joined { if (j.semantics == wire.semantics) return j; - bye(j.fd, .{}); + bye(j.fd, .{ .again = again }); _ = libc.close(j.fd); var jj = j; jj.rest.deinit(gpa); @@ -2949,7 +2953,7 @@ fn redial(gpa: Allocator, path: []const u8, session: []const u8, why: *[600]u8, var tries: u32 = 0; while (true) { why.* = @splat(0); - if (dial(gpa, path, session, why, have, view)) |j| return sameBuild(gpa, j, why); + if (dial(gpa, path, session, why, have, view)) |j| return sameBuild(gpa, j, why, view != null); // Another build, or another protocol (the daemon moved with its // session): no dial again will do. const words = std.mem.sliceTo(why, 0); -- cgit v1.3