Infos:
- Used Zammad version: 6.5.2
- Used Zammad installation type: zammad-helm 15.7.0 (with our own customisations), Kubernetes (GKE
- Operating system: Linux (container image on GKE)
- Browser + version: N/A (background job problem)
- Other info: External Cloud SQL PostgreSQL 16 and Elasticsearch. One scheduler replica, no liveness probe.
Expected behavior:
- After the database is restarted or fails over and comes back, the scheduler’s background services ( ProcessDelayedJobs , ProcessScheduledJobs ) reconnect on their own. Delayed jobs keep being processed, or the process exits so Kubernetes restarts it.
Actual behavior:
-
After a Cloud SQL maintenance restart, the scheduler logs the errors below. ProcessDelayedJobs does not process jobs again.
-
The scheduler pod stays Running with 0 restarts, so nothing alerts.
-
Delayed jobs pile up ( in production). New tickets don’t reach Elasticsearch, so they are missing from search until someone restarts the scheduler.
-
A scheduler restart recovers it and drains the backlog.
[Worker(host:... pid:1)] Error while reserving job: PQconsumeInput() FATAL: terminating connection due to administrator command SSL connection has been closed unexpectedly ERROR -- : BackgroundServices::Service::ProcessDelayedJobs#run() raised an error: There is an issue connecting with your hostname: <db-ip>. (ActiveRecord::DatabaseConnectionError) config/initializers/delayed_jobs_verify_db_connection.rb:9:in `recover_from' lib/background_services/service/process_delayed_jobs.rb:32 ... lib/background_services.rb:141:in `block in start_as_thread' ProcessScheduledJobs#run() logs the same DatabaseConnectionError .
Steps to reproduce the behavior:
-
Run Zammad 6.5.2 with an external PostgreSQL and the scheduler as a single pod.
-
Restart the database instance (a real restart; just killing connections with pg_terminate_backend recovers by itself).
-
The scheduler logs the errors above once the DB goes down.
-
Create a ticket after the DB is back. Delayed::Job.count keeps growing and the oldest job’s age keeps increasing. Nothing is processed and nothing is logged.
-
Restart the scheduler. The queue drains.
What we already tried:
-
POSTGRESQL_OPTIONS=pool=50&reaping_frequency=10 , from this thread. We repeated the DB restart with it and the delayed-job thread still did not recover.
-
Related: #3149 and #6558. #6558 handles forked children, but our ProcessDelayedJobs runs as a thread ( start_as_thread in the trace).
Questions:
-
Is there a supported way to make the scheduler’s background threads recover from a lost DB connection?
-
Does the #6558 fix, or any later release, cover thread-based services?
-
Is there a recommended health check (liveness probe or metric) for the background worker?