Skip to content

mw_procs: the victim of a kill is killed after it has inserted, not after a fixed time - #3

Merged
marcobambini merged 1 commit into
mainfrom
robust-mw-procs
Oct 11, 2026
Merged

marcobambini merged 1 commit into
mainfrom
robust-mw-procs

Conversation

@marcobambini

Copy link
Copy Markdown
Member

Il problema

Su main (run 38150066532, tentativo 2) il job linux-arm64 build + test è fallito su mw_procs:

rebase 1: one process killed after 0 of 1000000 inserts; the others 4800 of 4800; a new one 50 of 50; integrity ok
rebase 1: the killed process had -1 inserts acknowledged and 0 rows are there
FAIL test/mw_procs.c:126: killed > 0 && killed < 1000000

Il test uccide un processo 400 ms dopo averlo avviato (fase 2) e tutti e quattro dopo 600 ms (fase 3). Su un runner lento il processo non aveva ancora inserito nulla: i dati erano integri, non reggeva solo il tempo.

Correzione

wait_acked(path, id, n, limit_ms) attende che il processo abbia confermato almeno n inserimenti (un byte nel suo file .ack per ciascuno; limite 60 s) e solo dopo lo uccide:

fase prima dopo
2: un processo ucciso pause_ms(400) 200 inserimenti confermati
3: tutti e quattro uccisi pause_ms(600) 100 inserimenti confermati ciascuno

La dimensione del file è letta da un handle aperto (open + lseek), non con stat(): su Windows la dimensione di un file che un altro processo tiene aperto risulta in ritardo. I controlli finali sono invariati (nessuna riga confermata persa, al più una in più, database integro).

Verifica

  • Riproduzione del fallimento: con i figli avviati 700 ms in ritardo, il test vecchio fallisce come in CI (killed after 0 of 1000000 inserts, FAIL ... killed > 0) in entrambi i giri; quello nuovo passa (uccide dopo 258 e 201 inserimenti).
  • Esecuzione normale: passa (macOS arm64); la kill avviene dopo ~240 inserimenti.
  • Sotto carico: 72 esecuzioni a 24 in parallelo e 128 a 64 in parallelo senza fallimenti.

Da sapere

  • Non provato su Windows e Linux: la CI è la prova. La parte Windows usa open/lseek/close, già disponibili nel test per .ack e unlink.
  • Solo test: nessuna modifica al motore.
  • Resta fuori mw_syncwindow (fallito nella stessa run al tentativo 1): è un altro test temporizzato (mw_mp=1, ritardi di 15 e 30 ms) e non l'ho riprodotto né prima né dopo, quindi non lo tocco qui.

🤖 Generated with Claude Code

…fter a fixed time

The test killed a process 400 ms (one process) and 600 ms (all four) after it
started it. On a slow runner the process had not inserted anything yet:
"one process killed after 0 of 1000000 inserts", "FAIL mw_procs.c:126:
killed > 0 && killed < 1000000" (linux-arm64 of main, 15:21 UTC). The data
were whole: only the time did not hold.

wait_acked() waits until the process has acknowledged n inserts (a byte in its
.ack file for each), at most a minute, and the kill follows: 200 inserts for
the one of phase 2, 100 for each of the four of phase 3. The size is read from
an open handle (lseek): on Windows stat() of a file that another process holds
open lags behind.

Checked with the children of the test started 700 ms late: the old test fails
as in CI (killed after 0 of 1000000 inserts), the new one passes (258 and 201
inserts before the kill). The checks of the end are the same.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@marcobambini
marcobambini merged commit 033b14d into main Oct 11, 2026
53 of 54 checks passed
@marcobambini
marcobambini deleted the robust-mw-procs branch October 11, 2026 15:58
@marcobambini marcobambini mentioned this pull request Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant