Fix grant ledger ownership and truncated-record recovery

This commit is contained in:
dingo
2026-10-02 06:24:56 -04:00
parent c588be237c
commit 7ac587743c
6 changed files with 180 additions and 9 deletions
+30
View File
@@ -3564,3 +3564,33 @@ drained with `exit 0`.
Not done: the reviewer's own reproduction binaries target the removed `send` API and
were not rebuilt; equivalent regressions above replace them. The `ci-client` Docker
image and Gitea pipeline were not rerun here, and no cluster operation was performed.
## 2026-10-02 — consumed-grant ledger follow-up corrections
Resolved the two c588be2 review findings. Ledger open now acquires a nonblocking
exclusive lifetime lock on a stable sibling file before reading or compacting
(POSIX flock; Windows exclusive-sharing handle). Duplicate starts on either the
same port or a different port cannot replace the active ledger. The parser caps
records at 37 bytes before LF and rejects every nonempty incomplete final record
before compaction, preserving the original bytes. No ledger format migration or
simulation/protocol version change; valid existing files remain compatible.
Regression evidence: competing SessionServer starts fail with a ledger error;
the original server subsequently admits a grant, restarts, and rejects its replay.
Direct competing opens return busy. Every nonempty truncation of a valid final
record (including shortened numeric expiries) and an oversized line is rejected
without changing the file or creating a compaction temporary. Complete/empty files
and existing expired-entry compaction remain accepted.
Executed: Ubuntu GCC14 network CTest 1/1; Clang19 ASan/UBSan network CTest 1/1;
Windows MSVC network preset configure/build/CTest 1/1; clang-tidy19 on the changed
implementation and session tests with warnings as errors, no owned diagnostics;
clang-format19 on changed C++ files; git diff --check. The first restricted Windows
Ninja invocation stalled without compiling; its task-owned build processes were
stopped, then the same preset passed outside the restricted process environment.
Not rerun: Docker/Gitea, full PostgreSQL process suite, fuzzing, TSan, or live cluster
operations. No deployment performed. The text ledger detects malformed framing,
not syntactically valid corruption or deletion of entire records; ADR-0083 now states
that integrity limit explicitly. Client event-list bounds remain M9.8 work.