2026-11-03: Taskbase prod deadlocked on the incident advisory lock¶
Kind: reference (incident report)
Severity: critical · Status: resolved (the deadlock was cleared at about 06:50; the fix, taskbase#680, runs in taskbase-prod and taskbase-dev since 08:24) · Resolved by: a person (dunk), fixed by taskbase#680 (#2376); report by the operator agent · Duration: ~46 min of fault, 06:03:56–~06:50 UTC (not detected by an alert; detection time not recorded) · Taskbase task: #2377
Summary¶
OpenBao's volume on worker-2 stopped completing I/O from 05:32, which set off an alert burst on hetzner-mgmt (the storm of #2369). Alertmanager sent the alerts to Taskbase, and Taskbase's LockIncidents deadlocked its database pool: each notification held a pool connection while it waited for the cluster's advisory lock, and the lock holder could get no connection for its own work. From 06:03:56 every Taskbase prod request that needed the database ended in context canceled, until a 20-minute Alertmanager silence and pg_terminate_backend on the lock holder cleared it at about 06:50. The first pool fix in the deploy manifest (taskbase#675) broke the migrations and was reverted (taskbase#676). The lasting fix, taskbase#680 (#2376), takes the lock on a connection outside the pool, so no pool size can deadlock; taskbase#677 raised the pool to at least 20. Both run in prod as v1.253.3 since 08:24.
Task #2377 called the trigger a Hetzner maintenance window that moved OpenBao to worker-2 at 05:48. The cluster record contradicts that: OpenBao was already on worker-2, its volume hung at 05:32, and the 05:48:28 pod start was the #2362 agent's force-delete (see the #2369 report and pull request #1128).
Impact¶
- Services: the Taskbase prod API (
tasks-prod/platform-tasks-api): every request that needed the database failed withcontext canceled, including agent runners' claims and reports and Alertmanager's notifications to Taskbase. - Users: everyone who used Taskbase, people and agent runners, for about 46 minutes.
- Data: none lost as far as the record shows. Notifications that Alertmanager could not deliver during the deadlock or the silence may not have created or updated incident tasks (see Open questions).
- Duration: fault from 06:03:56 (first
context canceled) to about 06:50. No alert or probe detected it (see Root cause).
Timeline¶
All times UTC.
| Time | Event | Source |
|---|---|---|
| 05:32–05:33 | OpenBao's volume on worker-2 stops completing I/O; OpenBao is down from 05:33:44 and ExternalSecrets start failing |
#2369 report |
| 05:38:33 | ProbeFailed for OpenBao (#2362); from 05:48:52 ExternalSecretNotReady and KubePodNotReady fire, and from 05:50:22 hetzner-mgmt is in storm mode (#2369): the alert burst |
Alertmanager, #2369 report |
| 05:48:28 | The operator agent of #2362 force-deletes openbao-0; the replacement pod (same node) waits on MountVolume.SetUp … DeadlineExceeded and mounts only at 06:03:54 |
#2369 report, #1128 |
| 06:03:56 | First context canceled from the Taskbase prod API: the pool is deadlocked |
task #2377 |
| 06:30:07 | A person runs kubectl rollout restart on platform-tasks-api and platform-tasks-mcp (replica sets 659d9579c4, 766ccf9d49, revisions 153 and 142). The deadlock comes back with the next waiting notifications |
kubectl.kubernetes.io/restartedAt: 2026-11-03T07:30:07+01:00 on the replica sets |
| 06:35:06 | Both Deployments return to their Git template (replica sets 89656767c, 86d96d9594, revisions 154 and 143, without the restart annotation); a new API pod platform-tasks-api-89656767c-52mm5 starts. This is consistent with Flux reapplying Git, which drops the annotation kubectl set |
replica set history, pod creationTimestamp |
| before 06:50 | A person reads pg_stat_activity: one connection holds pg_advisory_lock(hashtext('incidents'), hashtext(cluster)), and the other pool connections wait for the same lock; the holder waits for a pool connection. pg_terminate_backend on the holder moves the deadlock to the next waiter |
task #2377 (exact times not recorded) |
| 06:42:05 | A person sets an Alertmanager silence for all alerts (alertname=~.+) until 07:02:05, comment "Taskbase incident-lock leak, 2026-11-03", so no further notifications reach Taskbase |
Alertmanager /api/v2/silences |
| 06:46:59 | taskbase#675 merged: pool_max_conns=20 in DATABASE_URL of deploy/prod/api-deployment.yaml |
pull request |
| 06:47:23 | The new API replica set 6d66f49b67 (revision 155) starts and crash-loops: migrations failed ... pq: unrecognized configuration parameter "pool_max_conns". The old pod keeps serving |
pod log, replica set |
| ~06:50 | Resolved: with the silence in place, pg_terminate_backend on the lock holder clears the deadlock and the API answers again |
task #2377 |
| 06:51:36 | taskbase#676 opened: revert of #675 | pull request |
| 06:53:03 | taskbase#677 opened: the pool opens with at least 20 connections, in code | pull request |
| 06:53:44 | Tasks #2376 (make the lock deadlock-free) and #2377 (this report) created | Taskbase |
| 06:54:10 | Task #2381 created by the #2369 run: the same lock failure seen from Alertmanager's side, webhook notifications timing out since 06:13 | Taskbase |
| 06:55:34 | NodeHighCPUUsage fires |
Alertmanager |
| 06:57:31 | TargetDown fires for tasks-prod (06:58:31 for tasks-dev) |
Alertmanager |
| 07:02:05 | The silence expires | Alertmanager |
| 07:03:03 | KubePodCrashLooping fires for tasks-prod (the #675 pod); NodeSystemSaturation at 07:03:10 |
Alertmanager |
| 07:12:09 | Flux taskbase-prod (and taskbase-dev) Ready=False: failed early due to stalled resources: [Deployment/tasks-prod/platform-tasks-api status: 'Failed'] |
flux get kustomizations -A |
| 07:12:33 | KubeDeploymentRolloutStuck fires for tasks-prod |
Alertmanager |
| 07:20:48 | taskbase#676 (revert of #675) merged | pull request |
| 07:21:28 | The platform-tasks-api Deployment starts progressing again after the revert |
Deployment Progressing condition |
| 07:48:23 | taskbase#677 (pool of at least 20, in code) merged | pull request |
| 07:48:35 | taskbase#680 (#2376) merged: the incident lock is taken on a connection outside the pool | pull request |
| 08:24:07 | platform-tasks-api v1.253.3, the first release after #677 and #680, starts in tasks-prod (replica set 76f957f86f) and becomes available at 08:24:18 |
pod startTime, Deployment condition |
| 08:30:29 | taskbase#683 (#2381) merged: tests for the lock release and the storm burst | pull request |
Root cause¶
LockIncidents in api/internal/task/incident_pg.go serializes the Alertmanager notifications of one cluster with a session advisory lock:
conn, err := s.db.Acquire(ctx)
...
conn.Exec(ctx, `SELECT pg_advisory_lock(hashtext('incidents'), hashtext($1))`, cluster)
...
return fn()
It takes a connection from the pool, blocks in pg_advisory_lock while holding that connection, and only then runs fn(), which needs more pool connections for its queries. The pool is opened by pgxpool.New with no size (api/internal/db/db.go), so pgx uses its default of max(4, CPUs). That is 4 on worker-1, which has 4 CPUs. One connection is held by LISTEN session_turn_pending (session.Listen), so three are left. When the alert burst sent concurrent notifications for the same cluster, one held the lock and two waited for it, each on a pool connection. The holder's fn() then waited for a free connection that the waiters would never give back, and every other request timed out in Acquire with context canceled. Restarting the pod or killing the holder did not help: the next notifications in Alertmanager's retry queue rebuilt the same state. Only stopping the notifications (the silence) together with killing the holder ended it.
Fixes:
- taskbase#675 (merged 06:46:59) set
pool_max_conns=20inDATABASE_URL. The migrations open the same URL with golang-migrate'spostgresdriver, which islib/pq.lib/pqpasses unknown parameters to the server, which rejects them:pq: unrecognized configuration parameter "pool_max_conns". The new pod exited before it served anything. - taskbase#676 (merged 07:20:48) reverted #675 and unblocked the rollouts.
- taskbase#677 (merged 07:48:23) opens the pool with at least 20 connections in code. On its own that only raises the number of concurrent waiters needed for the deadlock.
- taskbase#680 (#2376, merged 07:48:35) is the fix for the lock itself.
LockIncidentsnow takes the advisory lock on a connection of its own, outside the pool, and a process-wide gate lets only one call wait for or hold the lock, so a waiter holds no pool connection andfn()always gets one. Its testTestPostgresLockIncidentsSmallPool(pool of 2, 4 concurrent callers) fails on the old code and passes on the new. - taskbase#683 (#2381, merged 08:30:29) adds tests for the lock release on every path and for a storm burst of resolved notifications.
What the watchdog missed. Nothing raised an alarm for 46 minutes, because every health check of Taskbase answered "ok":
GET /api/health(api/cmd/server/main.go) returns{"status":"ok"}without touching the database.- The API Deployment's readinessProbe uses
/api/health, so the pod stayed Ready and was never restarted. - The Mac mini ops-agent watchdog (ADR 0020 §5) probes
https://taskbase.skatzi.com/api/healthand starts a DR session only after 5 minutes of failures. It saw a healthy Taskbase, so no DR session started. - The blackbox probe
taskbase-prod(cluster/hetzner-mgmt/blackbox-exporter/probes/probe.yaml) probes only the UI root andmcp.taskbase.skatzi.com/healthz.
Even a working alert would have reached Taskbase through the webhook that was deadlocked. The watchdog's GitHub dr issue path does not depend on Taskbase, so it is the right detector, once its probe can see the database.
Contributing, not the cause: at the same time, the Gitea act runners on worker-1 (gitea/gitea-act-runner-*, no CPU limit) used about 3.7 cores, and worker-1 ran at 94 % CPU (NodeHighCPUUsage from 06:55:34). The Taskbase API also runs on worker-1, with a CPU request of 50m and no limit. The load slowed the API, but the deadlock does not depend on CPU.
What the agent did¶
The recovery was done by a person before this task existed. The operator agent's run for #2377 was read-only on the cluster. It wrote no live state and set no silence.
Recovery by a person (dunk), from task #2377 and the cluster's records:
kubectl rollout restartoftasks-prod/platform-tasks-apiandplatform-tasks-mcpat 06:30:07. The deadlock came back.- Read
pg_stat_activityontasks-prod-dband found the advisory-lock holder and its waiters. pg_terminate_backendon the lock holder. On its own this moved the deadlock to the next waiter.- An Alertmanager silence of all alerts, 06:42:05–07:02:05, comment "Taskbase incident-lock leak, 2026-11-03". With it, step 3 cleared the deadlock at about 06:50.
- taskbase#675 merged; its pod crash-looped. taskbase#676 (revert) and taskbase#677 (pool in code) opened, and both were merged.
- Task #2376 was created; its agent's taskbase#680 was merged at 07:48:35. Task #2381's taskbase#683 followed at 08:30:29.
Read-only checks by the operator agent (task #2377), 07:13–07:16:
kubectl -n tasks-prod get pods,events,rs: the old API pod89656767c-52mm5is Running 1/1, and the #675 pod6d66f49b67-x8fzxis in CrashLoopBackOff, with the restart and rollback history above.kubectl -n tasks-prod logs platform-tasks-api-6d66f49b67-x8fzx:migrations failed ... pq: unrecognized configuration parameter "pool_max_conns".flux get kustomizations -A:taskbase-prodandtaskbase-devare Ready=False atmain@sha1:5da88b68, and that revision still contains #675.- Alertmanager
/api/v2/silencesand/api/v2/alertsthroughkubectl -n monitoring port-forward svc/alertmanager-operated 9093: the silence above is expired, and the alerts listed in the timeline are firing. - Read
incident_pg.go,db.goandmain.goof Skatzi/taskbase at5da88b68and the readinessProbe of the live Deployment: the root cause and the watchdog gap above. kubectl get pods --field-selector spec.nodeName=worker-1:gitea-act-runner-*have no CPU limit.
Read-only checks by the operator agent after review (task #2377), 09:41:
flux get kustomizations -A:taskbase-prodandtaskbase-devReady atmain@sha1:602cf9ee("Applied revision"); thetaskbaseGitRepository has stored that revision.kubectl -n tasks-prod get deploy,podsandkubectl -n tasks-dev get deploy,pods:platform-tasks-api,-mcpand-ui1/1 onv1.253.3in both namespaces; the prod API pod76f957f86f-q9j5tRunning since 08:24:07 with 0 restarts.- Read
api/internal/task/incident_pg.goof Skatzi/taskbase at602cf9ee:LockIncidentstakes the lock withpgx.ConnectConfigoutside the pool, behindincidentGate(taskbase#680).deploy/prod/api-deployment.yamlat #680's merge commit still namedv1.253.2, sov1.253.3is the first release with the fix. kubectl -n tasks-prod logs platform-tasks-api-76f957f86f-q9j5t | grep -c "context canceled\|lock incidents": 0.- Alertmanager
/api/v2/alertsand/api/v2/silences: onlyWatchdogandNodeHighMemoryUsage(monitoring) active; noAlertmanagerFailedToSendAlerts,KubePodCrashLooping,KubeDeploymentRolloutStuckorTargetDownfortasks-*; the catch-all silence is expired and no silence is active.
Resolution and verification¶
The deadlock ended at about 06:50, when the API answered again. The record holds no command output from that moment.
The incident is resolved: the cause is fixed and the fix runs in prod. Checked at 09:41 UTC:
flux get kustomizations -A:taskbase-prodandtaskbase-devReady atmain@sha1:602cf9ee.tasks-prodandtasks-dev:platform-tasks-api1/1 onv1.253.3, which contains taskbase#677 and taskbase#680. The prod pod has run since 08:24:07 with 0 restarts and has logged nocontext canceledorlock incidentserror.- Alertmanager: none of the alerts in the timeline still fires, and no silence is active.
The detection gap (no health check sees the database) is still open; see Follow-ups.
Follow-ups¶
-
2376 / taskbase#680 (done):
LockIncidentsno longer holds a pool connection while it waits for the advisory lock, so no pool size can be exhausted by an alert burst.¶ -
2381 / taskbase#683 (done): the same lock failure seen from Alertmanager's webhook side; tests for lock release and a storm burst.¶
- taskbase#676 and taskbase#677 (merged): the revert of #675 and the pool of at least 20, in code.
-
2389: make
/api/healthfail when the database pool cannot serve a query. The readinessProbe and the Mac mini watchdog then see a deadlock (what the watchdog missed).¶ -
2391: add Taskbase's database-backed health to the
taskbase-prod/taskbase-devblackbox probes, after #2389.¶ -
2392: give the Gitea act runners a CPU limit, so CI cannot saturate
worker-1.¶
References¶
- Alert: none for the deadlock itself. The burst that triggered it came from OpenBao's hung volume, 05:32–06:03 (#2369, #2362). Later:
NodeHighCPUUsage,TargetDown,KubePodCrashLooping,NodeSystemSaturation,KubeDeploymentRolloutStuck(tasks-prod). - Taskbase incident task: #2377; related: #2369 (the storm), #2362 (OpenBao), #2376 (lock fix), #2381 (webhook side)
- Reports: Incident storm on hetzner-mgmt (#2369); OpenBao's hung volume, pull request #1128 (#2362)
- Runs: the
operatorrun of #2377 - Pull requests: taskbase#675, taskbase#676, taskbase#677, taskbase#680, taskbase#683
- Runbook sections: none fits. The Mac mini watchdog is the detector that should have caught it.
Open questions¶
- When and how the deadlock was first noticed, and by whom: no alert fired, and the record does not say.
- The exact
pg_stat_activityrows: which PIDs, how many waiters, and the time of eachpg_terminate_backend. The record has only the summary in #2377. - Which alerts were in the burst, and which notifications Alertmanager dropped while Taskbase failed or the all-alerts silence was active. Incident tasks for them may be missing.
- Why OpenBao's volume on
worker-2stopped completing I/O from 05:32: not known, tracked in #2370 (owner). - The #2369 report saw Alertmanager's webhook fail from 06:13, while task #2377 gives 06:03:56 for the first
context canceled. The API logs from before the 06:35 pod start are gone, so which came first is not recorded. - The CPU figures (3.7 cores for the runners, 94 % on
worker-1) come from task #2377. This run could not re-check them, because the Metrics API (kubectl top) is not available.