Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

ClickhouseMigrator records migrations as done before running them, so a failed migration is skipped on the next run

Aperta
#9,956 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@effect-bot ci sta già lavorando.

Dal 26/10/2026.

  • #9959 di @baptisteArno — aperta

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

Hello,

Follow-up to #5440, now closed by #9248. That PR fixed the SQLite ledger DDL and removed BEGIN TRANSACTION for ClickHouse. One problem is left: the migrator writes every pending migration to the history table before running any of them. Without a transaction on ClickHouse, nothing undoes those rows when a migration fails.

Found by reading the source of effect 4.0.6. The same steps are still on main (16fe800):

  1. Migrator.ts#L269-L272 skips every migration with currentId <= latestMigrationId.
  2. Migrator.ts#L282-L293 inserts all required migrations into the history table.
  3. Migrator.ts#L296-L305 only then runs each migration.
  4. Migrator.ts#L327-L332 runs all of this outside a transaction for ClickHouse.

Scenario I expect from that code, with pending migrations 1, 2 and 3:

  • all three are recorded
  • migration 1 runs a CREATE TABLE that ClickHouse rejects, run fails
  • 2 and 3 never run
  • on the next start, latestMigrationId is 3, so all three are skipped and the app starts against a schema that never got them

No DROP or partial DDL needed, one rejected CREATE is enough.

I'm not asking for atomic DDL on ClickHouse. I'd just expect a migration to be recorded only once it succeeded, for example by inserting each row right after its own migration completes.

Separate thing that blocked my end-to-end repro

I couldn't confirm the scenario above in practice because of a different failure. With the real ClickhouseClient 4.0.6 against a local ClickHouse 26.9.22.3:

ClickhouseMigrator.run({
  loader: ClickhouseMigrator.fromRecord({
    "1_create_product_event": /* ... */
  })
})

with ClickhouseClient.make providing SqlClient.SqlClient. effect_sql_migrations gets created (SHOW TABLES lists it), then the run fails right away with SqlError "Failed to parse result", cause SyntaxError: JSON Parse error: Unexpected EOF. The application migration never ran. I didn't isolate which statement returns the empty body.

So I never got to the point of seeing a history row left behind by a failed migration. The ordering issue comes from reading the code, not from an observed run.

Lingua principale
TypeScript
Stelle
16.7k
Fork
808
Merge medio
10h 13m
PR unite (30g)
800

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Effect-TS/effect

Tutte le issue di Effect-TS/effect

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.