v0.14.1 — concurrent replicas can boot on Postgres
The PlatformKit OSS front door: one binary composing the nine-module starter.
Install
go install github.com/septagon-oss/platformkit@latestChanges
Concurrent replicas can boot on Postgres. A fix for a real failure in the profile v0.13.0 introduced as the production one.
Measured before the fix: six replicas starting simultaneously against a virgin database produced one success and five failures.
ensure schema: ERROR: duplicate key value violates unique constraint
"pg_type_typname_nsp_index" (SQLSTATE 23505)
CREATE TABLE IF NOT EXISTS reads as idempotent, and within one process it is — but on Postgres it is not concurrency-safe: competing backends collide inside the system catalog and all but one lose. Any rollout that starts several pods at once against a new database would have most of them crash-loop until one happened to finish first.
A session-scoped advisory lock is now held for the whole boot rather than around a single call, because schema is created in three separate places: the built-in module stores, the bootstrap-identity ledger, and any contributed module's own constructor (WithModules runs DDL the starter cannot see). Locking them one at a time would leave whichever site is added next unprotected. Seeding falls inside the lock too, so first-boot inserts serialize as well. A replica that crashes mid-boot releases the lock automatically, because the lock dies with its session.
Verified with this binary: six real processes racing a virgin Postgres all start, health answers, and the tenant and administrator are seeded exactly once. Two regression tests also run against real Postgres — six replicas on a virgin database, and six restarting against a populated one.
SQLite is unaffected: the embedded profile is a single process over one file, with the handle already pinned to one connection.
Compatibility
- Go 1.26 or newer.
- Pre-1.0 — pin this version. A minor release may change public API deliberately.
- No API or configuration change. On Postgres, boots now serialize their schema phase.
Links
| 📖 Documentation | https://septagon-oss.github.io/pk-docs/ |
| 💬 Discussions | https://github.com/septagon-oss/platformkit/discussions |
| 🔒 Security policy | https://github.com/septagon-oss/platformkit/blob/main/SECURITY.md |
| ⚖️ License | https://github.com/septagon-oss/platformkit/blob/main/LICENSE |