summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-22 21:22:18 -0300
committerGabriel Schneider <[email protected]>2026-11-22 22:44:21 -0300
commit111e53418c72717cb1decf56767d2f79188cf9fc (patch)
tree8bf584d2f1030215182c11dbd99553cab07d60aa /core
parentf148c600d35cca72c9c2ad2bb03086b9a8587c71 (diff)
downloadpardes-111e53418c72717cb1decf56767d2f79188cf9fc.tar.gz
pardes-111e53418c72717cb1decf56767d2f79188cf9fc.zip
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 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core')
-rw-r--r--core/replica.zig16
1 files changed, 10 insertions, 6 deletions
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);