Skip to content

Kubernetes: the startup probe kills a pod whose migrations run past five minutes, and the next pod waits for the killed one's locks, so a long migration never completes #825

Open

Description

@schmitch

Problem

Forge runs its migrations in forge_db::migrate (crates/server/src/main.rs:100) before it listens, so /healthz does not answer while they run. Both deployments give a pod 5 s × 60 = 300 s: the Helm chart's startupProbe (deploy/helm/forge/values.yaml:263-269) and the kustomize base's (deploy/kubernetes/base/deployment.yaml:70-75). Each migration runs in one transaction, without lock_timeout or statement_timeout (#603).

When the kubelet kills a pod in the middle of a migration:

  • PostgreSQL notices the lost client only once the running statement ends. Until then its backend keeps the migration's locks and sqlx's advisory lock, and then it rolls back.
  • The next pod waits for the advisory lock within its own 300 s, then starts the migration again.

In 2.2.0, 0011_retention_unlisted_at.sql scans component and rewrites every unlisted row while it holds ACCESS EXCLUSIVE. It can run longer than the probe allows on a large component table, or behind another session holding a lock on the table (a pg_dump). The upgrade then loops and never finishes, even with every 2.1 instance stopped as 788.upgrade.md asks.

This follows from reading the code; I have not reproduced it.

Expected

  • Migrations do not count against the startup probe. Either:
    • the server answers /healthz (not ready) while it migrates; or
    • a forge-server migrate command runs them outside the probed container, in a Helm pre-upgrade hook or an init container.
  • Until then, the upgrade notes say: on a large install, raise startupProbe.failureThreshold for the first start of a version that brings migrations.

Found in the 2.2.0 release review.

Activity

  1. added this to the Backlog milestone on Nov 3, 2026
  2. added
    bug
    on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions