Skip to content

Nexus outage and Postgres split history

Date 2026-10-01 (all times UTC; ICT = UTC+7)
Systems Nexus (nexus ns, registry.nexus.castis.io / nexus.castis.io), CNPG postgres-cluster (database ns)
Severity High — Docker registry down ~2.5 h; prod Postgres had no working replica for 3 days
Status Resolved. Follow-ups open (see §7)
Data loss None of significance (see §5)

1. Summary

At ~09:22 the Longhorn engine for the Nexus volume on nuc-a died unexpectedly. Nexus was killed mid-write and its H2 metadata database (/nexus-data/db/nexus.mv.db) was corrupted, so Nexus crash-looped on every start. The 19.3 GB of image blobs were unaffected. Nexus was restored from an on-volume June DB backup and the blob store was reconciled back into it; repositories, users (with original passwords), roles and packages created after June were recovered from the corrupt file.

While investigating a Pending Postgres pod, we found a separate, older incident: between 26 Sep 06:53 and 28 Sep 13:36 the CNPG cluster split into two timelines. Instance 3 (and replica 2 following it) took writes while instance 1 was stuck; CNPG then failed over to the 2-day-stale instance 1. Replica 2 stayed on the old timeline and did not replicate for 3 days while CNPG reported it healthy, so the primary was the only up-to-date copy. The missing data was identified (1,954 log rows), restored, and both replicas were rebuilt.


2. Timeline

Earlier (discovered today)

Time Event
2026-06-26 Nexus H2 DB corrupted once before; manually recovered (nexus.mv.db.bak left on volume).
2026-09-26 06:53 Postgres instance 1 stops receiving WAL (last file 000000060000005700000032.partial). Instance 3 continues as primary.
2026-09-26 ~18:01 Instance 3 flaps through timelines 7→25 (18 promotions in ~1 min) on nuc-a.
2026-09-28 13:36 CNPG fails over to instance 1 (timeline 7), which is 2 days behind. Instance 3 shuts down; replica 2 is left on timeline 26.

2026-10-01

Time Event
09:22:45 Last normal Nexus log line. Longhorn engine for pvc-3a2f5fb0… dies (DetachedUnexpectedly).
09:26–09:32 Longhorn auto-salvages, reattaches, rebuilds the mac-mini replica, creates a system snapshot.
~09:35 Longhorn auto-cleanup purges the 28 Sep system snapshot (only older copy of the volume).
09:27 → Nexus crash-loops: File is corrupted - unable to recover a valid set of chunks.
~09:36 Investigation starts. Corrupt DB copied off-volume (checksum verified). H2 Recover and MVStoreTool -repair both fail.
~09:44 Freeze: ArgoCD auto-sync off (nexus-prod, root-app-prod), cleanup CronJob suspended, Nexus scaled to 0.
09:47 June DB backup (with cleanup triggers paused) installed; corrupt DB kept as db.corrupt-20261001/.
09:49 Nexus up on June DB.
09:54–10:05 Reconcile dry run, then 2 real passes; search indexes rebuilt. 83 repos / 270 tags back; all 26 in-use cluster images verified.
~10:05 helm-hosted repo re-created + reconciled (2 charts). 4 missing npm versions re-uploaded from blob files (sha1 verified). NpmToken realm and helm / registry-read roles restored.
10:12 Users helm, june, regis-read, vietnam re-created and original password hashes restored for all users (operator-run script, ~2 min downtime).
~10:15 postgres-cluster-3 found Pending: topology spread selector counted pooler pods, blocking its node (nuc-a).
~10:19 Fix committed (06e76c3, cnpg.io/podRole: instance). Pod schedules but pg_rewind fails — split history discovered.
11:17–11:18 Nexus unfrozen: cleanup tasks rescheduled, CronJob resumed, ArgoCD auto-sync and Longhorn auto-cleanup restored.
11:26–11:30 Instance 3 data copied read-only to PVC pg3-rescue-copy (byte-identical, 4,333 files) and started as an isolated, read-only Postgres.
~11:35 Table-by-table comparison vs primary. Replica 2 found stuck on timeline 26 (no streaming since 28 Sep).
~11:38 1,954 coreapi.device_activity_log rows restored to primary (single transaction, ON CONFLICT DO NOTHING).
~11:40–11:47 Instance 3 re-cloned from primary. CNPG also rolled out 06e76c3 → primary restarted in place (~15 s unavailable at 11:47).
11:52 Instance 2 re-cloned. Cluster 3/3, both replicas streaming, 0 bytes lag.

3. Impact

  • Nexus / registry: unavailable ~09:22–09:49 (~27 min hard down), then partially available (incomplete catalog, missing users) until ~10:12. New image pulls using regis-read failed until ~10:12; running pods were unaffected.
  • Postgres: no working replica from 28 Sep to 1 Oct 11:47 (single point of failure). ~15 s primary restart at 11:47. Writes between 26 Sep 06:53 and 28 Sep 13:36 were absent from the primary until restored.

4. Root cause

  1. nuc-a storage instability. The Longhorn engine died on nuc-a (today), the Longhorn CSI driver dropped out on nuc-a (driver.longhorn.io not found), Postgres flapped 18 times on nuc-a (26 Sep), and Nexus corrupted on nuc-a (26 Jun). Underlying cause on the node is not yet identified.
  2. No backups anywhere. No Longhorn backup target, no CNPG backup / WAL archive (spec.backup empty), no Nexus "Backup H2 Database" task. This turned recoverable events into manual forensics:
  3. Postgres pg_rewind could not reconcile timelines (needed WAL was not archived).
  4. The only older Nexus volume state was a Longhorn system snapshot, which was purged automatically after the replica rebuild.
  5. Health checks hid the problem. CNPG reported replica 2 as healthy for 3 days although it was on a different timeline and not streaming.
  6. Contributing: the CNPG topology spread selector (cnpg.io/cluster only) also matched pooler pods, which kept instance 3 Pending.

5. Data loss assessment

Nexus

Item Result
Docker images / tags (83 repos, 270 tags) Recovered via reconcile
helm-hosted (apisix 2.15.0, cert-manager v1.21.0) Recovered
npm @playtelly/capability-apps 0.2.0–0.8.0, design-tokens, tellyboard-theme Recovered (latest = 0.8.0)
Users, roles, realms (incl. NpmToken) Recovered, original passwords
Old image versions deleted by cleanup before today Already gone (expected)
Nexus tasks created after 26 Jun: "Compact blob store" (blobstore.compact) and "Docker - Delete unused manifests and images" (repository.docker.gc) Lost — need re-creating (used by nexus-docker-cleanup)
Other settings changed after 26 Jun Not found in audit; possible minor drift

Postgres (old copy as of 28 Sep 13:36 vs current primary)

Data Rows only in old copy Action
coreapi.device_activity_log (kind power, 28 Sep, 62 devices) 1,954 Restored
zitadel session events (one login, 28 Sep 02:42) 4 events + 3 queue/projection rows Not restored — expired; manual event-store inserts are unsafe
authapi.refresh_tokens 4 Not restored — expired
Rows updated during the gap (coreapi.devices ×3, authapi.users ×1) — No loss — all updated again on primary since
playtelly, dummy 0 —

Net loss: none of significance.


6. Changes made

Committed (06e76c3): services/infrastructure/postgress/prod/03-cluster.yaml — topology spread selector now cnpg.io/cluster + cnpg.io/podRole: instance.

Runtime only (not in Git): - Nexus DB replaced by June backup + reconcile; helm-hosted repo, roles, NpmToken realm, users, npm uploads. - Postgres: 1,954 rows inserted; instances 2 and 3 re-cloned. - All temporary freezes reverted (ArgoCD auto-sync, CronJob, cleanup tasks, Longhorn auto-cleanup-system-generated-snapshot=true).

Backups / leftovers kept (delete after ~1 week if nothing is reported missing): | Location | Contents | |---|---| | Nexus volume /nexus-data/db.corrupt-20261001/ | Corrupt DB + June recovery files | | Nexus volume /nexus-data/db/nexus.mv.db.before-userfix-20261001101234 | DB before password-hash restore | | PVC database/pg3-rescue-copy (nuc-a, Retain) | Verified copy of old instance 3 (timeline 26) | | Released PVs pvc-05961986… (nuc-a), pvc-56d54d0a… (nuc-b) | Old instance 3 and 2 data dirs (Retain) | | Released PVs pvc-2e0e063d…, pvc-41c7583d…, pvc-a6a16c12… | Older postgres-cluster volumes predating this incident |


7. Follow-up actions

# Action Priority
1 Configure CNPG backups + WAL archive (e.g. SeaweedFS S3). High
2 Configure a Longhorn backup target + recurring backup for the Nexus volume. High
3 Add a scheduled Nexus "Admin - Backup H2 Database" task; commit the off-site backup CronJob (nexus/backup-cronjob.yml, to mac-mini) that was drafted but not committed. High
4 Investigate nuc-a (disk / kernel / Longhorn instance-manager logs around 09:22 today and 26 Sep 18:01). High
5 Alert on replication: pg_stat_replication row count / lag on the primary, and replica timeline ≠ primary timeline. High
6 Re-create Nexus tasks "Compact blob store" and "Docker - Delete unused manifests and images" (docker-hosted); verify nexus-docker-cleanup (incl. new commit 4b8bba5, Docker GC) after its 02:00 run. Medium
7 Consider moving Nexus off a single pinned node (nodeSelector: nuc-a). Medium
8 After ~1 week, delete the leftovers in §6. Low

8. Lessons learned

  • Freeze order matters. Longhorn's system-snapshot auto-cleanup should be disabled first when a volume needs forensics; here the only older snapshot was purged before it could be protected.
  • "Ready" is not "replicating". CNPG readiness hid a replica on the wrong timeline for 3 days; check pg_stat_replication on the primary.
  • Pod-spec changes on CNPG restart the primary. The topology fix triggered a rolling update including an in-place primary restart; schedule such changes in a quiet window and announce them.
  • Reconcile from the blob store is effective for Nexus metadata loss, but anything not stored in blobs (users, roles, tasks, realms, repo definitions) must come from elsewhere — another reason for regular DB backups.