fix: bump eventsourced/pg to v2.0.2 and harden startup error logging #851

Merged
argoyle merged 2 commits from fix/pg-v2-startup-logging into main 2026-05-25 20:45:23 +00:00
Owner

Why

schemas is crash-looping at startup (exit 0 / Completed, no error in logs). Same root cause as dancefinder: pg v1.19.0+ auto-runs an idempotency migration whose partial index uses a non-IMMUTABLE now() predicate, which modern Postgres rejects (functions in index predicate must be marked IMMUTABLE), failing pg.New(). schemas was on the broken pg v1.20.0.

What

1. Dependency bump (fixes the crash)

  • gitlab.com/unboundsoftware/eventsourced/pg/v2v2.0.2 (the fixed, importable release; v2.0.0/v2.0.1 lacked the required /v2 module path)
  • gitlab.com/unboundsoftware/eventsourced/eventsourcedv1.23.0 (required by pg/v2)
  • Only the import path changes (.../pg.../pg/v2); package stays pg, no call sites change.

2. Startup error logging (diagnosability)

  • main() now also writes startup errors to stderr (survives the deferred OTel SDK shutdown that was swallowing them) and os.Exit(1) so the pod reports failed instead of Completed.

Verification

go build ./..., go vet, full go test ./... all pass. eventsourced v1.23.0's metrics refactor is unused by schemas.

Mirrors dancefinder PRs #437 (bump) + #436 (logging).

## Why schemas is crash-looping at startup (exit 0 / `Completed`, no error in logs). Same root cause as dancefinder: pg v1.19.0+ auto-runs an idempotency migration whose partial index uses a non-IMMUTABLE `now()` predicate, which modern Postgres rejects (`functions in index predicate must be marked IMMUTABLE`), failing `pg.New()`. schemas was on the broken pg v1.20.0. ## What **1. Dependency bump (fixes the crash)** - `gitlab.com/unboundsoftware/eventsourced/pg/v2` → **v2.0.2** (the fixed, importable release; v2.0.0/v2.0.1 lacked the required `/v2` module path) - `gitlab.com/unboundsoftware/eventsourced/eventsourced` → **v1.23.0** (required by pg/v2) - Only the import path changes (`.../pg` → `.../pg/v2`); package stays `pg`, no call sites change. **2. Startup error logging (diagnosability)** - `main()` now also writes startup errors to stderr (survives the deferred OTel SDK shutdown that was swallowing them) and `os.Exit(1)` so the pod reports failed instead of `Completed`. ## Verification `go build ./...`, `go vet`, full `go test ./...` all pass. eventsourced v1.23.0's metrics refactor is unused by schemas. Mirrors dancefinder PRs #437 (bump) + #436 (logging).
argoyle added 2 commits 2026-05-25 20:35:22 +00:00
pg v1.19.0+ auto-runs an idempotency migration whose partial index used a
non-IMMUTABLE now() predicate, which Postgres rejects at creation. That
failed pg.New() at startup and crash-looped the service (silently, exit 0).
schemas was on the broken pg v1.20.0.

The fix is in pg's v2 line; v2.0.0/v2.0.1 were unconsumable (go.mod module
path lacked the required /v2 suffix), corrected in v2.0.2. Bump to:

  - gitlab.com/unboundsoftware/eventsourced/pg/v2 v2.0.2
  - gitlab.com/unboundsoftware/eventsourced/eventsourced v1.23.0 (required by pg/v2)

Only the import path changes (.../pg -> .../pg/v2); package stays `pg`, no
call sites change.
fix: log startup errors to stderr and exit non-zero
schemas / vulnerabilities (pull_request) Successful in 1m49s
schemas / check (pull_request) Successful in 3m5s
schemas / check-release (pull_request) Successful in 3m45s
pre-commit / pre-commit (pull_request) Successful in 6m15s
schemas / build (pull_request) Successful in 5m51s
schemas / deploy-prod (pull_request) Has been skipped
381816a66e
When start() returns an error, main() logged it via the slog logger and
returned normally (exit 0), so a crash-looping pod showed as "Completed"
with no error in the logs: start() defers the OTel SDK shutdown, tearing
down the log exporter before main() logs, so with LOG_FORMAT=otel the
record never reaches Alloy.

Also write the error to stderr (always captured by `kubectl logs`) and
os.Exit(1) so the container is correctly reported as failed.
argoyle scheduled this pull request to auto merge when all checks succeed 2026-05-25 20:40:33 +00:00
argoyle merged commit 3f22773f58 into main 2026-05-25 20:45:23 +00:00
argoyle deleted branch fix/pg-v2-startup-logging 2026-05-25 20:45:25 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: unboundsoftware/schemas#851