CI: il PostgreSQL dei test non si riavvia più a metà della suite #99

Merged
Alby96 merged 6 commits from ci-postgres into main 2026-11-15 16:27:30 +01:00
Owner

Chiude #98.

Che cosa succedeva

Nel lavoro test (postgres) c'erano due problemi, tutti e due legati al disco lento dell'esecutore.

1. Il server ripartiva a metà dei test (57P03, EndOfStreamException). Il registro del server, ora stampato a fine lavoro, dice ogni volta:

LOG:  untracked child process (PID 248) exited with exit code 2
LOG:  terminating any other active server processes

Il controllo di salute pg_isready di Docker superava i suoi 3 secondi. Docker chiudeva la shell e pg_isready passava al processo 1 del contenitore, cioè PostgreSQL stesso. Quando usciva, PostgreSQL lo prendeva per un suo processo andato in crash e ripartiva. Non c'entrava la memoria (OOMKilled false, nessun evento oom) e non c'entrava il codice di Anubis.

2. I test scadevano (Timeout during reading attempt, errore=database nel test desktop). Ogni DROP DATABASE dei test forza un checkpoint, uno alla volta. Sul disco dell'esecutore la sincronizzazione arrivava a 37 secondi e i DROP in coda superavano i 30 secondi del client.

I dettagli sono nell'ADR 0015.

Che cosa cambia

  • Il servizio postgres della CI parte con --init, e il controllo è pg_isready … -t 5 con un tempo massimo di 15 secondi. In docker-compose.yml: init: true e lo stesso controllo.
  • Solo nella CI, il server dei test nasce senza sincronizzazioni su disco: fsync, synchronous_commit e full_page_writes spenti con POSTGRES_INITDB_ARGS. È un server da buttare. docker-compose.yml e i database veri non cambiano.
  • Il nuovo comando tasks ci-service-log stampa a fine lavoro registro, stato, eventi e memoria del contenitore PostgreSQL. Li legge dal socket di Docker, senza componenti nuovi.
  • Nuovo ADR docs/adr/0015-postgresql-con-init-nei-container.md.

Prove

  • Senza correzione, la suite ripetuta tre volte sullo stesso server (esecuzione 315) ha fatto 4 riavvii. Con --init (esecuzione 321) ha fatto 3 giri da 359 test senza riavvii.
  • Esecuzioni normali verdi due volte di fila, sia push sia pull_request: 327 e 328, poi 330 e 331 dopo l'unione con main (373 test). In tutte, nessun riavvio, nessun 57P03 e nessun tempo scaduto. La suite su PostgreSQL scende da 6-10 minuti a meno di 2.
  • ./tasks.ps1 check è verde in locale.

Il commit temporaneo della prova a tre giri è già annullato.

🤖 Generated with Claude Code

Chiude #98. ## Che cosa succedeva Nel lavoro `test (postgres)` c'erano due problemi, tutti e due legati al disco lento dell'esecutore. **1. Il server ripartiva a metà dei test** (`57P03`, `EndOfStreamException`). Il registro del server, ora stampato a fine lavoro, dice ogni volta: ``` LOG: untracked child process (PID 248) exited with exit code 2 LOG: terminating any other active server processes ``` Il controllo di salute `pg_isready` di Docker superava i suoi 3 secondi. Docker chiudeva la shell e `pg_isready` passava al processo 1 del contenitore, cioè PostgreSQL stesso. Quando usciva, PostgreSQL lo prendeva per un suo processo andato in crash e ripartiva. Non c'entrava la memoria (`OOMKilled false`, nessun evento `oom`) e non c'entrava il codice di Anubis. **2. I test scadevano** (`Timeout during reading attempt`, `errore=database` nel test desktop). Ogni `DROP DATABASE` dei test forza un checkpoint, uno alla volta. Sul disco dell'esecutore la sincronizzazione arrivava a 37 secondi e i `DROP` in coda superavano i 30 secondi del client. I dettagli sono nell'ADR 0015. ## Che cosa cambia - Il servizio `postgres` della CI parte con `--init`, e il controllo è `pg_isready … -t 5` con un tempo massimo di 15 secondi. In `docker-compose.yml`: `init: true` e lo stesso controllo. - Solo nella CI, il server dei test nasce senza sincronizzazioni su disco: `fsync`, `synchronous_commit` e `full_page_writes` spenti con `POSTGRES_INITDB_ARGS`. È un server da buttare. `docker-compose.yml` e i database veri non cambiano. - Il nuovo comando `tasks ci-service-log` stampa a fine lavoro registro, stato, eventi e memoria del contenitore PostgreSQL. Li legge dal socket di Docker, senza componenti nuovi. - Nuovo ADR `docs/adr/0015-postgresql-con-init-nei-container.md`. ## Prove - Senza correzione, la suite ripetuta tre volte sullo stesso server (esecuzione 315) ha fatto 4 riavvii. Con `--init` (esecuzione 321) ha fatto 3 giri da 359 test senza riavvii. - Esecuzioni normali verdi due volte di fila, sia `push` sia `pull_request`: 327 e 328, poi 330 e 331 dopo l'unione con `main` (373 test). In tutte, nessun riavvio, nessun `57P03` e nessun tempo scaduto. La suite su PostgreSQL scende da 6-10 minuti a meno di 2. - `./tasks.ps1 check` è verde in locale. Il commit temporaneo della prova a tre giri è già annullato. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Alby96 added 1 commit 2026-11-15 11:41:56 +01:00
Print the PostgreSQL service log at the end of the CI job (refs #98)
ci / test (postgres) (push) Successful in 8m16s
ci / test (sqlite) (push) Successful in 5m16s
ci / test (postgres) (pull_request) Successful in 11m38s
ci / test (sqlite) (pull_request) Successful in 4m58s
ci / image (push) Successful in 1m42s
ci / image (pull_request) Successful in 47s
0a9a8a38ec
The job log shows the tests losing every connection but not why the server
went into recovery. A new tasks command reads the service container's log,
state and memory through the Docker socket the runner mounts in the job.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Alby96 added 1 commit 2026-11-15 12:16:36 +01:00
TEMPORARY: run the PostgreSQL suite three times on one server, push only (refs #98)
ci / test (postgres) (pull_request) Skipped
ci / image (pull_request) Waiting for needed jobs
ci / test (postgres) (push) Failing after 11m1s
ci / image (push) Skipped
72f4cbe0a5
Two clean runs did not show the restart. This collects the server log of a
failure sooner and lists Docker's events for the service container (oom, kill,
die). Reverted before the merge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Alby96 added 1 commit 2026-11-15 13:06:06 +01:00
Run the test PostgreSQL behind an init and let pg_isready give up before Docker (refs #98)
ci / test (postgres) (pull_request) Skipped
ci / image (pull_request) Waiting for needed jobs
ci / test (postgres) (push) Successful in 23m7s
ci / image (push) Skipped
6ea303e1dc
The server log of a failing job shows every restart as 'untracked child
process exited with exit code 2'. A health check that outlives its 3-second
timeout leaves pg_isready to PostgreSQL, which is PID 1 in its container;
when pg_isready exits the postmaster takes it for a crashed backend and
restarts every connection. --init reaps such orphans, and pg_isready -t 5
under a 15-second timeout is never cut off. Same change in docker-compose.yml.
ADR 0015.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Alby96 added 1 commit 2026-11-15 14:27:56 +01:00
Back to the normal CI jobs after the stress run (refs #98)
ci / test (sqlite) (push) Successful in 4m34s
ci / test (sqlite) (pull_request) Successful in 4m56s
ci / test (postgres) (push) Failing after 9m37s
ci / image (push) Skipped
ci / test (postgres) (pull_request) Successful in 8m44s
ci / image (pull_request) Successful in 1m21s
73f2345047
Reverts the temporary three-round job. With --init and the shorter pg_isready,
three PostgreSQL suites on one server passed with no restart (run 321), where
the same run without them restarted the server four times (run 315). The
Docker events in the service log step stay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Alby96 changed title from WIP: CI, PostgreSQL dei test che si riavvia a metà della suite to CI: il PostgreSQL dei test non si riavvia più a metà della suite 2026-11-15 14:28:05 +01:00
Alby96 added 1 commit 2026-11-15 15:30:27 +01:00
Turn off disk syncs on the CI test PostgreSQL (refs #98)
ci / test (postgres) (push) Successful in 3m13s
ci / test (sqlite) (push) Successful in 4m23s
ci / test (postgres) (pull_request) Successful in 3m41s
ci / test (sqlite) (pull_request) Successful in 4m28s
ci / image (push) Successful in 1m46s
ci / image (pull_request) Successful in 1m1s
74809068af
With the restarts gone, a rerun still failed 7 tests on read timeouts. The
server log shows why: every DROP DATABASE of the tests forces an immediate
checkpoint, one at a time, and on the runner's disk the sync alone took up
to 37 seconds, so queued drops passed the client's 30-second timeout. The
service is a throwaway, so initdb now sets fsync, synchronous_commit and
full_page_writes off. docker-compose.yml and real databases keep them on.
ADR 0015 updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Alby96 added 1 commit 2026-11-15 16:02:51 +01:00
Merge main into ci-postgres (refs #98)
ci / test (postgres) (push) Successful in 4m8s
ci / test (sqlite) (push) Successful in 5m16s
ci / test (postgres) (pull_request) Successful in 3m44s
ci / test (sqlite) (pull_request) Failing after 5m38s
ci / image (pull_request) Skipped
ci / image (push) Successful in 1m6s
63ae9d580a
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner

Risultati delle esecuzioni normali (lavoro test (postgres)):

Commit Esecuzione Evento Esito Test Durata
7480906 327 push ✓ 359 1,3 min
7480906 328 pull_request ✓ 359 1,3 min
63ae9d5 (con main e la Fase 7) 330 push ✓ 373 1,6 min
63ae9d5 (con main e la Fase 7) 331 pull_request ✓ 373 1,5 min

In tutte e quattro: nessun riavvio del server, nessun 57P03 e nessun tempo scaduto. Il registro mostra init true e Sync to disk skipped.

Nel frattempo main senza questa correzione (esecuzione 329) ha perso 24 test nello stesso modo.

Seconda causa, trovata strada facendo. Con la sola prima correzione, il rilancio dell'esecuzione 324 non ha più fatto ripartire il server. Però 7 test sono scaduti, perché ogni DROP DATABASE forza un checkpoint e sul disco dell'esecutore la sincronizzazione arrivava a 37 secondi. Per questo il PostgreSQL della CI ora nasce senza sincronizzazioni su disco (commit 7480906, ADR 0015 aggiornato). Il docker-compose.yml e i database veri restano come prima. Il checkpoint più lento è passato da 37 s a 0,001 s, e la suite su PostgreSQL da 6-10 minuti a meno di 2.

./tasks.ps1 check è verde in locale anche dopo l'unione con main (373 test: 371 superati, 2 ignorati).

Risultati delle esecuzioni normali (lavoro `test (postgres)`): | Commit | Esecuzione | Evento | Esito | Test | Durata | |---|---|---|---|---|---| | `7480906` | 327 | push | ✓ | 359 | 1,3 min | | `7480906` | 328 | pull_request | ✓ | 359 | 1,3 min | | `63ae9d5` (con `main` e la Fase 7) | 330 | push | ✓ | 373 | 1,6 min | | `63ae9d5` (con `main` e la Fase 7) | 331 | pull_request | ✓ | 373 | 1,5 min | In tutte e quattro: nessun riavvio del server, nessun `57P03` e nessun tempo scaduto. Il registro mostra `init true` e `Sync to disk skipped`. Nel frattempo `main` senza questa correzione (esecuzione 329) ha perso 24 test nello stesso modo. **Seconda causa, trovata strada facendo.** Con la sola prima correzione, il rilancio dell'esecuzione 324 non ha più fatto ripartire il server. Però 7 test sono scaduti, perché ogni `DROP DATABASE` forza un checkpoint e sul disco dell'esecutore la sincronizzazione arrivava a 37 secondi. Per questo il PostgreSQL della CI ora nasce senza sincronizzazioni su disco (commit `7480906`, ADR 0015 aggiornato). Il `docker-compose.yml` e i database veri restano come prima. Il checkpoint più lento è passato da 37 s a 0,001 s, e la suite su PostgreSQL da 6-10 minuti a meno di 2. `./tasks.ps1 check` è verde in locale anche dopo l'unione con `main` (373 test: 371 superati, 2 ignorati).
Alby96 merged commit a77aa1b7eb into main 2026-11-15 16:27:30 +01:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: BalboSoft/Anubis#99