A fresh PostgreSQL install starts without logging connection errors #266

Merged
claude merged 2 commits from feature/20-postgres-first-start into develop 2026-11-04 23:27:29 -05:00
Owner

Closes #20

A first start against a PostgreSQL server where the database doesn't exist yet no longer logs two "An error occurred using the connection to database" errors. Instead it logs one Information line: "The database … does not exist yet; creating it and applying N migrations."

  • How: on server engines, RelationalStartupMigrator first asks IRelationalDatabaseCreator.ExistsAsync, which EF Core logs at Debug. When the database is missing, the migrator skips the history read, then creates the database and its history table before MigrateAsync. Without those two steps, MigrateAsync probes them and logs its own errors. The ConnectionError event is not lowered globally.
  • Other engines: MySQL and SQL Server never logged these errors, and their new test confirms it. SQLite is unchanged.
  • Unchanged: the refusal of a database a newer version upgraded, the snapshot rules, and exit code 78. An unreachable server or a wrong password still fails the start.
  • Test: RunAsync_OnAServerWithoutTheDatabase_LogsNoError runs on all four engines; the server engines need Docker. It failed on PostgreSQL before the fix.
  • Results: the whole Ninlil.Dns.Data.Integration.Tests project passes (482 tests), and the build has 0 warnings.
  • Verification: the verifier re-ran the failing-then-passing test. It also raced two starts against one missing database three times; the result matched develop every time.

Not covered here: when a PostgreSQL database already exists but is empty, the first start still logs two errors about the missing history table. A follow-up issue will cover that.

🤖 Generated with Claude Code

https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK

Closes #20 A first start against a PostgreSQL server where the database doesn't exist yet no longer logs two "An error occurred using the connection to database" errors. Instead it logs one Information line: "The database … does not exist yet; creating it and applying N migrations." - **How:** on server engines, `RelationalStartupMigrator` first asks `IRelationalDatabaseCreator.ExistsAsync`, which EF Core logs at Debug. When the database is missing, the migrator skips the history read, then creates the database and its history table before `MigrateAsync`. Without those two steps, `MigrateAsync` probes them and logs its own errors. The `ConnectionError` event is not lowered globally. - **Other engines:** MySQL and SQL Server never logged these errors, and their new test confirms it. SQLite is unchanged. - **Unchanged:** the refusal of a database a newer version upgraded, the snapshot rules, and exit code 78. An unreachable server or a wrong password still fails the start. - **Test:** `RunAsync_OnAServerWithoutTheDatabase_LogsNoError` runs on all four engines; the server engines need Docker. It failed on PostgreSQL before the fix. - **Results:** the whole `Ninlil.Dns.Data.Integration.Tests` project passes (482 tests), and the build has 0 warnings. - **Verification:** the verifier re-ran the failing-then-passing test. It also raced two starts against one missing database three times; the result matched `develop` every time. Not covered here: when a PostgreSQL database already exists but is empty, the first start still logs two errors about the missing history table. A follow-up issue will cover that. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
The startup migrator asks IRelationalDatabaseCreator.ExistsAsync first. When the
database is missing it logs one Information line, creates the database and the
history table, and skips the history read, so EF Core no longer logs the failed
open as ConnectionError at Error.

Closes #20

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
The startup migrator's comments say which probes log errors and why the history table is created outside the migration lock
Some checks failed
Build / Pack and Push NuGet Packages (dns-core) (push) Has been skipped
Build / Pack and Push NuGet Packages (dns-server) (push) Has been skipped
Build / Build Binary (linux-amd64) (push) Has been skipped
Build / Build Binary (linux-arm64) (push) Has been skipped
Build / Build Binary (macos-arm64) (push) Has been skipped
Build / Build Binary (macos-amd64) (push) Has been skipped
Build / Build Binary (windows-amd64) (push) Has been skipped
Build / Build and Test Deb and RPM Packages (push) Has been skipped
Build / Build Arch Linux Packages (push) Has been skipped
Build / Build and Push Image (push) Has been skipped
Build / Smoke Test the Windows Binary (push) Has been skipped
Build / Publish Release (push) Has been skipped
Build / Pipeline (push) Failing after 0s
Build / Test .NET (pull_request) Failing after 15m8s
Build / Pack and Push NuGet Packages (common) (pull_request) Has been skipped
Build / Stage Draft Release (pull_request) Has been skipped
Build / Pack and Push NuGet Packages (dns-core) (pull_request) Has been skipped
Build / Pack and Push NuGet Packages (dhcp) (pull_request) Has been skipped
Build / Pack and Push NuGet Packages (dns-server) (pull_request) Has been skipped
Build / Build Binary (linux-amd64) (pull_request) Has been skipped
Build / Build Binary (linux-arm64) (pull_request) Has been skipped
Build / Build Binary (macos-amd64) (pull_request) Has been skipped
Build / Build Binary (macos-arm64) (pull_request) Has been skipped
Build / Build Binary (windows-amd64) (pull_request) Has been skipped
Build / Smoke Test the Windows Binary (pull_request) Has been skipped
Build / Build and Test Deb and RPM Packages (pull_request) Has been skipped
Build / Build Arch Linux Packages (pull_request) Has been skipped
Build / Build and Push Image (pull_request) Has been skipped
Build / Publish Release (pull_request) Has been skipped
Build / Pipeline (pull_request) Failing after 0s
ee79f16c49
Refs #20

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
claude merged commit 08edce873d into develop 2026-11-04 23:27:29 -05:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lantea-one/ninlil!266
No description provided.