All requests, including /api/v1/status, hang while the PostgreSQL database is unavailable – please fail fast and report the database state

Backlog

All requests, including /api/v1/status, hang while the PostgreSQL database is unavailable – please fail fast and report the database state

avatar

Hi support,


Environment

PowerShell Universal 2026.3.4, Linux container on Kubernetes, PostgreSQL plugin (Plugins__0=PostgreSQL), PostgreSQL 17, single node behind a reverse proxy that uses /api/v1/status for readiness and liveness.


Steps to reproduce

1. Run PSU with the PostgreSQL plugin; wait until /api/v1/status returns 200.

2. Make the database unreachable (stop the PostgreSQL container so its host name no longer resolves).

3. Request /api/v1/status, /api/v1/alive, the admin console and an app.

4. Start the database again.


Observed

- Every request, including /api/v1/status and /api/v1/alive, hangs instead of answering. A short outage (about 16 s) and a long one (12 min) were tested. In the long one, nothing answered for the whole time.

- The log fills with Npgsql "Name or service not known" and RetryLimitExceededException from NpgsqlRetryingExecutionStrategy (6 retries). This adds up to roughly a minute per database call.

- Health probes time out, the orchestrator removes the instance, and users only see a blank page with no message.

- After about 10 minutes, the liveness probe restarts PSU. Without the database it fails at start and keeps restarting until the database is back.

- Once the database is back, PSU serves again within about 15 seconds. If it was not restarted, it recovers by itself.


Expected

- Requests that need the database fail fast, e.g. 503 with Retry-After, instead of blocking for the whole retry cycle.

-Login answers within a bounded time and reports the database state, e.g. 503 "database unavailable". Then load balancers can react, and liveness checks can tell "database down" from "PSU hung".

- Apps and the admin console show a maintenance or error message instead of a blank page.


Feature request

- Configurable database resilience in appsettings: retry count, maximum retry delay, and a short separate timeout for health checks.

- A documented database check in the status APIs; /api/v1/alive is not documented.

- A built-in maintenance page while the database is unavailable.

- Documentation of the behaviour during database outages and failover for PostgreSQL and SQL Server.



Thanks,

René

All Comments (1)

avatar

Hello Mordecai,

Thank you for the detailed report and the clear test results.

We reproduced the behaviour in our lab with PowerShell Universal 2026.3.4 and PostgreSQL 17, using the same test of stopping the database container.

We confirmed it as a bug in PowerShell Universal, and I have reported it to the development team with our test results.

Your suggestions for configurable retry settings, a fast database check, a maintenance page and documentation are included in the report.

Here is what we found.

The PostgreSQL plugin uses the Entity Framework Core retry strategy with its default settings, 6 retries with a growing delay.

Each database call made during an outage waits for that whole cycle before it fails.

In our test, /api/v1/status returned 503 "Database unavailable." only after about 137 seconds, and /api/v2/status after about 85 seconds.

Every probe with a 5 second timeout failed, so from the probe's side the endpoint looks hung.

The login page returned a 500 error with the raw retry message after about 86 seconds, which a reverse proxy usually turns into a timeout or a blank page.

/api/v1/alive is an internal endpoint used by the login and loading screens.

It returned 200 with a databaseUnavailable flag in the body, so it is not suited for health probes.

Static files and the TCP port kept answering at once during the whole outage, which shows that the PSU process itself was not hung.

At startup, version 2026.3.4 runs the database migrations before it starts to listen.

When the database cannot be reached at that moment, the process stops within a few seconds, which explains the restart loop you saw.

Once the database came back, PSU served requests again within a few seconds without a restart.

There is currently no setting to change the retry count, the retry delay, or a separate timeout for health checks.

Until a fix is available, these Kubernetes settings should avoid the restarts and give users a clear message:

  • Liveness probe: use a TCP check on the PSU port instead of /api/v1/status, so a database outage no longer restarts the pod.

  • Readiness probe: keep /api/v1/status with a short timeout, so the pod leaves the service while the database is down and returns once PSU answers 200 again.

  • Startup probe: use a TCP check that allows enough failures for the first start.

  • Init container: wait for PostgreSQL before PSU starts, so a cold start during an outage waits instead of looping.

  • Reverse proxy: serve a custom maintenance page for 502, 503 and 504 responses, so users see a message instead of a blank page.

Here is an example, adjust the port and host names to your deployment:

initContainers:
  - name: wait-for-postgres
    image: postgres:17-alpine
    command: ["sh", "-c", "until pg_isready -h <postgres-host> -p 5432; do sleep 2; done"]
containers:
  - name: psu
    startupProbe:
      tcpSocket: { port: 5000 }
      periodSeconds: 10
      failureThreshold: 30
    readinessProbe:
      httpGet: { path: /api/v1/status, port: 5000 }
      periodSeconds: 10
      timeoutSeconds: 5
      failureThreshold: 3
    livenessProbe:
      tcpSocket: { port: 5000 }
      periodSeconds: 20
      failureThreshold: 6

If you want the liveness probe to prove that HTTP still answers, a GET on a static file such as /assets/favicon.ico answered within milliseconds in our outage test.

It is not a documented health endpoint, so the TCP check remains the safer choice.

Please note that the init container only runs when the pod starts, so it does not cover a container restart inside a running pod.

The status endpoints are documented here: https://docs.devolutions.net/powershell-universal/config/hosting/high-availability/

I will keep you updated on the progress of the report.

Let me know if you have questions about the probe settings.

Best regards,

Patrick Ouimet