Bläddra i källkod

docs: my snapshot fingerprint was wrong - the log sequence is the writer's, not the file's

Committed sequence monotonicity as 'the check validation cannot replace' one
commit ago. The database owner refuted it: the log line records the sequence of
the writer that ran, not the header of the file that survived, so in the bad
interleaving each writer logs its own increasing sequence while the kept file
carries the other's. A monotonic series is consistent with the bug.

The real discriminator is per file and needs no tooling - CALSNAP1 magic at
offset 0, WAL sequence u64 at offset 24, doc count at offset 32, verified
against two independent sources. All 5 surviving files match their log lines,
and that is 5 of 414 completions: the rest are permanently unverifiable.
fszontagh 1 månad sedan
förälder
incheckning
d83840d060
1 ändrade filer med 3 tillägg och 1 borttagningar
  1. 3 1
      CLAUDE.md

+ 3 - 1
CLAUDE.md

@@ -604,7 +604,9 @@ docker run -d --name svapi-dev -p 8080:8080 -e SMARTBOTIC_VECTORAPI_KEY=dev svap
 - **A SNAPSHOT RACE WE HAVE NOT HIT, A NEAR-MISS WITH A 47-SECOND MARGIN THAT WE HAVE, AND A CHECK THAT DISCRIMINATES WHERE VALIDATION CANNOT.** Database 2.21.1 fixes two races found by refusing to dismiss a 1-in-7 flaky test as noise - which is the headline lesson and belongs to them: **(a)** eviction removed a document from memory a moment before recording its stub, so a snapshot could write it as DELETED, and **(b)** the shutdown's final snapshot and the periodic one could run at once and clobber each other's file within a second. Neither is pinned by a test, stated plainly by them: once in ~20 runs, and the mutex revert passed 10/10, so a test there would be a coin flip pretending to be a check.
   **OUR EXPOSURE TO (a) IS CURRENTLY NIL AND WAS REAL, AND THE DECIDING QUANTITY IS EVICTION.** The memory check now reads `95831 docs, 0 evicted` at 46% of budget, where on 2026-10-20 under 2.17.2 it read `52584 docs, 33000 evicted` - the streaming writer removed the pressure that drove eviction. So this is "promptly, not urgently", and it returns the day the store outgrows the budget again. Note the shape: a defect whose precondition is a RESOURCE STATE, so the exposure moves on its own with no code change and no deploy.
   **MY FIRST FRAMING OF (b) WAS TOO REASSURING AND THEY CORRECTED IT.** I wrote that `validate_after_write` plus `cleanup_only_if_verified` narrow (b) to "a refused snapshot rather than a corrupt one". That is true of the failure they observed - the writer deletes the file and throws, so the WAL is not truncated and older snapshots are kept - and it is NOT true of every interleaving. The one they cannot exclude: **a valid, complete file from one writer passes verification while the OTHER writer's sequence is the one used to truncate the WAL, so the writes in between are in neither.** Validation cannot see that, because the file it checks is genuinely fine. Improbable, not impossible, and the reason 2.21.1 serializes the writers instead of trusting validation.
-  **THE FINGERPRINT FOR THAT CASE IS SNAPSHOT-SEQUENCE MONOTONICITY, AND THE BOOT IDENTITY CANNOT SUBSTITUTE FOR IT.** If A's file is kept while B's sequence truncates, the `Created snapshot at sequence N` series stops increasing. Measured: **414 completions retained, strictly increasing from 70,672 on 10-03 to 762,091 on 10-22 - no instance.** The boot arithmetic this file already recommends (`Replayed N from sequence X` plus `WAL sequence X`) is **self-consistent whatever was lost**, so a clean recovery line is not evidence either way - it reads like evidence, which is exactly why that has to be written down next to it.
+  **I PROPOSED SEQUENCE MONOTONICITY AS THE FINGERPRINT, COMMITTED IT AS "THE CHECK VALIDATION CANNOT REPLACE", AND IT CANNOT DETECT THIS AT ALL. The database owner refuted it within the hour: `Created snapshot at sequence N` logs the sequence of the WRITER that ran, not the header of the file that ended up on disk - so in the bad interleaving each writer logs its own, still-increasing sequence while the surviving FILE carries the other's. A monotonic log series is CONSISTENT with the bug.** Measured and useless: 414 completions, strictly increasing from 70,672 on 10-03 to 762,091 on 10-22. That is a true observation supporting a claim it cannot reach, which is this file's oldest trap, committed in the same breath as a paragraph congratulating itself on finding a discriminator.
+  **THE REAL DISCRIMINATOR IS PER FILE, AND IT IS READABLE WITHOUT ANY TOOLING: compare each snapshot FILE's header sequence against the log line that named that file.** The header is plain at the front of the `.dat`, before the compressed body - **`CALSNAP1` magic at offset 0, the WAL sequence as a little-endian u64 at offset 24, the document count at offset 32.** Verified by the numbers agreeing with two independent sources rather than by guessing at the layout: the newest file reads sequence 762091 against its log line's 762091, and doc count 95715 against the server's own memory check. Measured on prod: **all 5 surviving files MATCH their log lines** (760831/95298, 760987/95350, 761011/95358, 761761/95605, 762091/95715). **COVERAGE STATED RATHER THAN IMPLIED: 5 files of 414 completions - every older one was cleaned up, so 409 are permanently unverifiable.** A clean result here means "no instance among the files that still exist", never "no instance".
+  **And the boot identity cannot substitute for either check**: `Replayed N from sequence X` plus `WAL sequence X` is **self-consistent whatever was lost**, so a clean recovery line is not evidence in either direction - it reads like evidence, which is why it has to be written down next to it.
   **AND PROD HAS RUN THE PAIRING, 47 SECONDS CLEAR.** Hunting back-to-back EQUAL sequences found 91; 87 are ~3600 s apart (an idle hour, the timer firing with nothing written - benign), three are 180-710 s, and **one is 51 s apart and is the periodic snapshot followed by the shutdown's final one**: `10:46:41 Created snapshot at sequence 96309`, `10:47:28 Received signal 15`, `10:47:32 Created snapshot at sequence 96309 / Final snapshot taken on shutdown`. Same two writers, same state, both completing, separated by 47 s of luck rather than by any mechanism. On a slower snapshot or an earlier stop that is an overlap.
   **The count on its own meant nothing, and I nearly reported it: "91 back-to-back equal sequences" sounds alarming and is almost entirely idle hours. Only the GAP DISTRIBUTION separates an idle timer from two writers at the same state** - median 3604 s, min 51 s. A frequency without its distribution is the same error as a rate without its base rate.