Targets fix/user-data-autovacuum-gap so the fix lands before !145 reaches main.
The bug
TuneUserDataAutovacuum guarded with database as? any SQLDatabase before running a PL/pgSQL DO block. SQLite conforms to SQLDatabase too, so the guard passed and SQLite received SQL it cannot parse:
[Migrator] Failed prepare [database-id: sqlite, error: error: near "DO": syntax error,
migration: FlamenetRelay.TuneUserDataAutovacuum]
Fatal error: Error raised at top level
Fluent treats that as a failed migration and the process exits during boot, so the relay crash-loops. The three test relays on the box (relays-relay1/2/3-1) had 15 restarts each and could not boot at all.
This was not confined to test
messenger-relay-1 carries FN_DB=/data/relay.sqlite alongside FN_POSTGRES_URL, so it has a sqlite database-id registered. Merging !145 as-is would have crash-looped production the same way.
The fix
prepare and revert now share one helper that checks the dialect rather than the protocol.
I read both literals out of the resolved sources instead of assuming them, because a wrong string fails in the more dangerous direction: it would skip Postgres too, and the tuning would silently never apply with nothing to indicate it. PostgresDialect.name is "postgresql"; SQLiteDialect.name is "sqlite".
Tests
AutovacuumDialectTests.swift, four cases: the boot schema migrates cleanly on SQLite (the shape that broke), the migration alone is a no-op rather than an error there, the dialect literal is pinned, and the migration is still registered in the boot schema.
Verification
Swift Testing: 702 tests in 64 suites, passed.
XCTest: 57 tests, 0 failures.
Worth flagging for this repo: a plain swift test on this toolchain runs only the Swift Testing suites and reports Test run with 702 tests ... passed while silently skipping all 57 XCTest cases. The XCTest half needs --enable-xctest --disable-swift-testing. A green Swift Testing summary on its own is not a green suite.
Side note
CI already caught this: !145's pipeline is red, because the harness runs autoMigrate() on SQLite. What went wrong is that the red branch was deployed to the test relays anyway, where the crash loop and Swift's default backtracer (--unwind precise, 221s, 3-4 GB each) filled the box's RAM and swap and caused 18 OOM kills, including an unrelated CI build in another repo.
Targets `fix/user-data-autovacuum-gap` so the fix lands before !145 reaches `main`.
## The bug
`TuneUserDataAutovacuum` guarded with `database as? any SQLDatabase` before running a PL/pgSQL `DO` block. **SQLite conforms to `SQLDatabase` too**, so the guard passed and SQLite received SQL it cannot parse:
```
[Migrator] Failed prepare [database-id: sqlite, error: error: near "DO": syntax error,
migration: FlamenetRelay.TuneUserDataAutovacuum]
Fatal error: Error raised at top level
```
Fluent treats that as a failed migration and the process exits during boot, so the relay crash-loops. The three test relays on the box (`relays-relay1/2/3-1`) had **15 restarts each** and could not boot at all.
## This was not confined to test
`messenger-relay-1` carries `FN_DB=/data/relay.sqlite` alongside `FN_POSTGRES_URL`, so it has a sqlite database-id registered. Merging !145 as-is would have crash-looped **production** the same way.
## The fix
`prepare` and `revert` now share one helper that checks the dialect rather than the protocol.
I read both literals out of the resolved sources instead of assuming them, because a wrong string fails in the more dangerous direction: it would skip Postgres too, and the tuning would silently never apply with nothing to indicate it. `PostgresDialect.name` is `"postgresql"`; `SQLiteDialect.name` is `"sqlite"`.
## Tests
`AutovacuumDialectTests.swift`, four cases: the boot schema migrates cleanly on SQLite (the shape that broke), the migration alone is a no-op rather than an error there, the dialect literal is pinned, and the migration is still registered in the boot schema.
## Verification
- Swift Testing: **702 tests in 64 suites**, passed.
- XCTest: **57 tests, 0 failures**.
Worth flagging for this repo: a plain `swift test` on this toolchain runs only the Swift Testing suites and reports `Test run with 702 tests ... passed` while silently skipping all 57 XCTest cases. The XCTest half needs `--enable-xctest --disable-swift-testing`. A green Swift Testing summary on its own is not a green suite.
## Side note
CI already caught this: !145's pipeline is red, because the harness runs `autoMigrate()` on SQLite. What went wrong is that the red branch was deployed to the test relays anyway, where the crash loop and Swift's default backtracer (`--unwind precise`, 221s, 3-4 GB each) filled the box's RAM and swap and caused 18 OOM kills, including an unrelated CI build in another repo.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Targets
fix/user-data-autovacuum-gapso the fix lands before !145 reachesmain.The bug
TuneUserDataAutovacuumguarded withdatabase as? any SQLDatabasebefore running a PL/pgSQLDOblock. SQLite conforms toSQLDatabasetoo, so the guard passed and SQLite received SQL it cannot parse:Fluent treats that as a failed migration and the process exits during boot, so the relay crash-loops. The three test relays on the box (
relays-relay1/2/3-1) had 15 restarts each and could not boot at all.This was not confined to test
messenger-relay-1carriesFN_DB=/data/relay.sqlitealongsideFN_POSTGRES_URL, so it has a sqlite database-id registered. Merging !145 as-is would have crash-looped production the same way.The fix
prepareandrevertnow share one helper that checks the dialect rather than the protocol.I read both literals out of the resolved sources instead of assuming them, because a wrong string fails in the more dangerous direction: it would skip Postgres too, and the tuning would silently never apply with nothing to indicate it.
PostgresDialect.nameis"postgresql";SQLiteDialect.nameis"sqlite".Tests
AutovacuumDialectTests.swift, four cases: the boot schema migrates cleanly on SQLite (the shape that broke), the migration alone is a no-op rather than an error there, the dialect literal is pinned, and the migration is still registered in the boot schema.Verification
Worth flagging for this repo: a plain
swift teston this toolchain runs only the Swift Testing suites and reportsTest run with 702 tests ... passedwhile silently skipping all 57 XCTest cases. The XCTest half needs--enable-xctest --disable-swift-testing. A green Swift Testing summary on its own is not a green suite.Side note
CI already caught this: !145's pipeline is red, because the harness runs
autoMigrate()on SQLite. What went wrong is that the red branch was deployed to the test relays anyway, where the crash loop and Swift's default backtracer (--unwind precise, 221s, 3-4 GB each) filled the box's RAM and swap and caused 18 OOM kills, including an unrelated CI build in another repo.mentioned in commit
65db60e5a5