diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-22 23:53:14 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-22 23:56:41 -0300 |
| commit | f52b6256927431e90af58af2f91eaac7e9799bf5 (patch) | |
| tree | abd5e1e04d0ce1896ff6fc17168d4d59e232ebde /core/replica.zig | |
| parent | aee54cf0a3a328b4ec704bc2c59996428c35f6e8 (diff) | |
| download | pardes-f52b6256927431e90af58af2f91eaac7e9799bf5.tar.gz pardes-f52b6256927431e90af58af2f91eaac7e9799bf5.zip | |
dump: a join's dump and its digest are one moment: the dump asks the host nothing and hands back the digest it was made at: a client that came back while 9P requests were live (a script reading /screen, the /mnt/9p mount) loaded the session's dump and refused it as another session's, exiting for good while its session was there (fault D, reports/pardes-upgrade-back.md: the upgrade row's rejoin, about 3 in 75 on one CPU, and its family in pair_exec_reaps): the join's dump stat'd each pane's file for which were on disk (core/dump.zig `dumpWith` -> `onDisk` -> exec.kindOf, a `.kind` tape site that gives up the turn, tape.out), a 9P open, read or release (none waits for quiet: ninep/tree.zig `needsQuiet`) was answered in that gap by a connection task, and `Peers.join` then took the welcome's digest over the moved `fs` (tape.digestOf after the dump): the client's load, from before the request, could not be it; and the request, recorded after the join's cut, was in the client's next unit too; `fs` is ruled replicated state, as it was: every 9P request is a taped input each replica replays (Core.zig `serveFs`), a write on an open reads its record (the half line, the results, the lock, the held writes: the previous change's fifteen kinds, the tests at the replica's surface below them), and its dump carries what its digest hashes (the property's 300 joins); what was wrong was the moment, not the field; now `dumpJoin` returns `.{ bytes, digest }`, the digest taken in it after the dump with nothing between, `Peers.join` and `Authority.join` take it from there (no caller can take it at another moment), a join's dump writes `on_disk` as none (only a revival reads it, from an image: `image` keeps its stat; a client's load discards it: loadKnowing's `on_disk` is null for `load`), and a turn given up while the dump is made fails it (`error.TurnGivenUp`: the join is refused in words, `that session could not be dumped`, never loaded otherwise); `byteDump` (tests only) is the join's dump with its blobs in place, as its tests take it; the previous change's moment test passes (the join asks the host nothing: the stat that let the request in is never made, the turn's yields do not move); core-test under the filter `join` 52/61 (9 skipped)
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.zig | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/core/replica.zig b/core/replica.zig index 957e6d5f..75aa94e1 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -296,7 +296,8 @@ pub const Authority = struct { const u = try a.unit(0, a.seq); var blobs: std.ArrayListUnmanaged(walk.Deferred) = .empty; defer blobs.deinit(a.core.gpa); - const state = try pardes.dump.dumpJoin(a.core, &blobs); + const dumped = try pardes.dump.dumpJoin(a.core, &blobs); + const state = dumped.bytes; defer a.core.gpa.free(state); tape.resync(&a.t); var whole: std.ArrayListUnmanaged(u8) = .empty; @@ -308,7 +309,7 @@ pub const Authority = struct { pos = b.at; } try whole.appendSlice(a.gpa, state[pos..]); - return .{ .view = k, .unit = u, .dump = try whole.toOwnedSlice(a.gpa), .digest = tape.digestOf(a.core) }; + return .{ .view = k, .unit = u, .dump = try whole.toOwnedSlice(a.gpa), .digest = dumped.digest }; } /// Client `client` gone as `Peers.leave` lets one go: its view kept for @@ -1978,7 +1979,7 @@ pub const Peers = struct { // undo, registers) left out, pinned, and streamed by the client's // writer thread: the step pays for the state, not for the text. var blobs: std.ArrayListUnmanaged(walk.Deferred) = .empty; - const bytes = pardes.dump.dumpJoin(core, &blobs) catch |err| { + const dumped = pardes.dump.dumpJoin(core, &blobs) catch |err| { blobs.deinit(core.gpa); core.undrawn &= ~(@as(u8, 1) << @intCast(k)); core.closeView(.at(k)); @@ -1987,6 +1988,7 @@ pub const Peers = struct { var why: [96]u8 = undefined; return daemon.refuseReplica(fd, std.fmt.bufPrint(&why, "that session could not be dumped: {t}", .{err}) catch "that session could not be dumped"); }; + const bytes = dumped.bytes; var whole = bytes.len; for (blobs.items) |b| { pardes.memory.pin(b.bytes); @@ -2008,7 +2010,7 @@ pub const Peers = struct { if (ps.next_id == 0) ps.next_id = 1; // The session's digest as dumped, for the joiner to check its load by // (a pair's client, its own boot: `writeJoin`). - const digest = tape.digestOf(core); + const digest = dumped.digest; peer.digest = digest; peer.welcome_len = (wire.encodeServer(&peer.welcome, .{ .welcome = .{ .pid = @intCast(libc.getpid()), .session = ps.name[0..@min(ps.name.len, wire.max_name)], .client = peer.id, .view = peer.view, .dump_len = whole, .gmtoff = gmtoff(), .digest = digest, .semantics = wire.semantics, .blobs = @intCast(blobs.items.len) } }) catch unreachable).len; if (ps.threads) peer.writer = std.Thread.spawn(.{}, Peer.writeLoop, .{peer}) catch null; @@ -3380,11 +3382,11 @@ fn farJoinOnce(ps: *Peers, core: *Pardes, have: ?*Have) !Joined { var fds: [2]c_int = undefined; if (libc.socketpair(libc.AF.UNIX, libc.SOCK.STREAM | libc.SOCK.CLOEXEC, 0, &fds) != 0) return error.NoSocket; var blobs: std.ArrayListUnmanaged(walk.Deferred) = .empty; - const state = pardes.dump.dumpJoin(core, &blobs) catch |err| { + const state = (pardes.dump.dumpJoin(core, &blobs) catch |err| { _ = libc.close(fds[0]); _ = libc.close(fds[1]); return err; - }; + }).bytes; var whole = state.len; for (blobs.items) |b| whole += b.bytes.len; const peer = try ps.gpa.create(Peer); @@ -3431,7 +3433,7 @@ fn joinedNow(a: *Authority, id: u16, view: u8) !*Replica { const was = Stepping.begin(&a.t, null); var blobs: std.ArrayListUnmanaged(walk.Deferred) = .empty; defer blobs.deinit(a.core.gpa); - const state = try pardes.dump.dumpJoin(a.core, &blobs); + const state = (try pardes.dump.dumpJoin(a.core, &blobs)).bytes; defer a.core.gpa.free(state); tape.resync(&a.t); was.end(); @@ -4857,7 +4859,7 @@ test "a join's dump, its blobs put back where they go, is the session's dump" { defer a.core.gpa.free(whole); var blobs: std.ArrayListUnmanaged(walk.Deferred) = .empty; defer blobs.deinit(a.core.gpa); - const state = try pardes.dump.dumpJoin(a.core, &blobs); + const state = (try pardes.dump.dumpJoin(a.core, &blobs)).bytes; defer a.core.gpa.free(state); try std.testing.expect(blobs.items.len > 0); try std.testing.expect(state.len + 20000 <= whole.len); @@ -4990,7 +4992,7 @@ test "a far join is sent each blob once: joined again with them on disk or in th // What the session's list will say: its blobs, those of one text once. var listed: std.ArrayListUnmanaged(walk.Deferred) = .empty; defer listed.deinit(a.core.gpa); - a.core.gpa.free(try pardes.dump.dumpJoin(a.core, &listed)); + a.core.gpa.free((try pardes.dump.dumpJoin(a.core, &listed)).bytes); var distinct: std.AutoHashMapUnmanaged([32]u8, usize) = .empty; defer distinct.deinit(gpa); var distinct_bytes: u64 = 0; |
