fix: bump eventsourced/pg to v2.0.2 and harden startup error logging (#851)
schemas / vulnerabilities (push) Successful in 1m43s
schemas / check (push) Successful in 2m25s
schemas / check-release (push) Successful in 2m38s
Release / release (push) Failing after 49s
pre-commit / pre-commit (push) Successful in 6m30s
schemas / build (push) Successful in 5m8s
schemas / deploy-prod (push) Successful in 1m37s

## 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).

Reviewed-on: #851
This commit was merged in pull request #851.
This commit is contained in:
2026-05-25 20:45:22 +00:00
parent d2d053e559
commit 3f22773f58
3 changed files with 14 additions and 7 deletions
+8 -1
View File
@@ -24,7 +24,7 @@ import (
"github.com/vektah/gqlparser/v2/ast"
"gitlab.com/unboundsoftware/eventsourced/amqp"
"gitlab.com/unboundsoftware/eventsourced/eventsourced"
"gitlab.com/unboundsoftware/eventsourced/pg"
"gitlab.com/unboundsoftware/eventsourced/pg/v2"
"gitea.unbound.se/unboundsoftware/schemas/cache"
"gitea.unbound.se/unboundsoftware/schemas/domain"
@@ -66,6 +66,13 @@ func main() {
cli,
); err != nil {
logger.With("error", err).Error("process error")
// start() defers the OTel SDK shutdown, so by the time we get here the
// log exporter may already be torn down and the line above never
// reaches Alloy. Write to stderr too so startup failures are always
// visible in `kubectl logs`, and exit non-zero so the container is
// reported as failed (CrashLoopBackOff) instead of "Completed".
fmt.Fprintf(os.Stderr, "fatal: process error: %v\n", err)
os.Exit(1)
}
}