Title: bug: a database outage longer than ~30 seconds permanently stops cron schedules (self-hosted) · Issue #5120 · triggerdotdev/trigger.dev · GitHub
Open Graph Title: bug: a database outage longer than ~30 seconds permanently stops cron schedules (self-hosted) · Issue #5120 · triggerdotdev/trigger.dev
X Title: bug: a database outage longer than ~30 seconds permanently stops cron schedules (self-hosted) · Issue #5120 · triggerdotdev/trigger.dev
Description: Provide environment information Self-hosted Trigger.dev v4.8.3 (Docker Compose), linux/arm64 External PostgreSQL reached through a TCP proxy, Redis 7 The same code is in v4.8.5 and on main as of 2026-11-12 Describe the bug A short Postgr...
Open Graph Description: Provide environment information Self-hosted Trigger.dev v4.8.3 (Docker Compose), linux/arm64 External PostgreSQL reached through a TCP proxy, Redis 7 The same code is in v4.8.5 and on main as of 20...
X Description: Provide environment information Self-hosted Trigger.dev v4.8.3 (Docker Compose), linux/arm64 External PostgreSQL reached through a TCP proxy, Redis 7 The same code is in v4.8.5 and on main as of 20...
Opengraph URL: https://github.com/triggerdotdev/trigger.dev/issues/5120
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"bug: a database outage longer than ~30 seconds permanently stops cron schedules (self-hosted)","articleBody":"### Provide environment information\n\n- Self-hosted Trigger.dev v4.8.3 (Docker Compose), linux/arm64\n- External PostgreSQL reached through a TCP proxy, Redis 7\n- The same code is in v4.8.5 and on `main` as of 2026-11-12\n\n### Describe the bug\n\nA short PostgreSQL outage permanently stops cron schedules. Ours lasted about 35 seconds and stopped 8 of 123 active schedules. They never fired again until we called the admin recover endpoint (`/admin/api/v1/environments/{id}/schedules/recover`). Nothing in the dashboard shows that a schedule has stopped.\n\nWhy it happens:\n\n1. Each tick is one schedule-engine worker job, `schedule.triggerScheduledTask`. The next tick is only registered at the end of a successful handler (`ScheduleEngine.triggerScheduledTask` → `registerNextTaskScheduleInstance`).\n2. `scheduleWorkerCatalog` gives that job `retry: { maxAttempts: 5 }` (`internal-packages/schedule-engine/src/engine/workerCatalog.ts`). With the redis-worker defaults (factor 2, 1 s base, randomized) all five attempts finish in about 15–30 seconds.\n3. If PostgreSQL is unreachable for that whole window, the job goes to the dead-letter queue. No job exists for the instance any more, so nothing registers the next tick. The chain is broken for good.\n4. The handler is called with `finalAttempt: false, // TODO: implement retry logic` (`internal-packages/schedule-engine/src/engine/index.ts`), so there is no last-attempt fallback.\n\n### Reproduction repo\n\nNo repo needed; this reproduces on a stock self-hosted install.\n\n### To reproduce\n\n1. Self-host v4.8.3 with a few `* * * * *` schedules in a production environment.\n2. Stop PostgreSQL for about 75 seconds, starting just before a minute boundary. Then start it again.\n3. Check Redis. Most schedules now have no entry in `schedule:schedule:{queue:schedule-engine-worker:}items` and one in `…dlq`. They never fire again.\n\nIn an isolated test with four schedules, three stopped permanently after a 76 second outage.\n\n### Suggested fix\n\n- **Reconcile periodically.** Run the existing `recoverSchedulesInEnvironment` logic on a timer for all active, non-development instances, using `enqueueOnce` so a live job is never replaced. This makes the chain self-healing whatever the cause. We run a 60 second loop as a local patch; with it, a 12 minute outage recovered six seconds after PostgreSQL returned, with no duplicate runs.\n- **A longer retry budget for this job**, for example `maxAttempts: 15` with `maxTimeoutInMs: 60_000` (about 9–10 minutes). A short outage then costs a late tick instead of a lost schedule. `calculateNextSchedulableOccurrence` already skips expired slots, so there is no backlog replay.\n- **An idempotency key on the scheduled trigger** (instance id + schedule time). Today a retry after \"trigger succeeded, next-tick registration failed\" can trigger the same slot twice, and a longer retry budget makes that more likely.\n- **Make it visible.** A metric or dashboard state for \"active schedule with no pending job\" would surface this.\n\n### Additional information\n\nThe webapp log at the time showed `Failed to trigger scheduled task` and then `Failed to register schedule instance`, both with Prisma `Can't reach database server`, for each affected instance. The dead-letter entries carry the same error with `attempt: 4`.\n","author":{"url":"https://github.com/shrinidhi4u","@type":"Person","name":"shrinidhi4u"},"datePublished":"2026-11-12T06:09:59Z","url":"https://github.com/triggerdotdev/trigger.dev/issues/5120"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:0fee1b3c-6baf-70a6-6f4c-74a3e4d3b083 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DE10:22F43A:FAA857:15F3B79:6AFAD890 |
| html-safe-nonce | afa6cb061303bb209fa54b0de8faf86b973a686e60e6c150173410d8ed26d78e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERTEwOjIyRjQzQTpGQUE4NTc6MTVGM0I3OTo2QUZBRDg5MCIsInZpc2l0b3JfaWQiOiI4MTU0MjAzMjg5NjY3OTUwNzM2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 6face34a2a464c0e9edea829f38c9b4bcb36a75858a6883e37d1a64b4746efff |
| hovercard-subject-tag | issue:6344002786 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/triggerdotdev/trigger.dev/5120/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8a9bbe6692a7f799f3a163107d8aba3414c5cf9fce5075b45820232c78822104/triggerdotdev/trigger.dev/issues/5120 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8a9bbe6692a7f799f3a163107d8aba3414c5cf9fce5075b45820232c78822104/triggerdotdev/trigger.dev/issues/5120 |
| og:image:alt | Provide environment information Self-hosted Trigger.dev v4.8.3 (Docker Compose), linux/arm64 External PostgreSQL reached through a TCP proxy, Redis 7 The same code is in v4.8.5 and on main as of 20... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | shrinidhi4u |
| hostname | github.com |
| expected-hostname | github.com |
| None | 02f4c00e74911c7cd779fc232c3130cee49eb39fd0ed4bfe3eea3b82c7c18084 |
| turbo-cache-control | no-preview |
| go-import | github.com/triggerdotdev/trigger.dev git https://github.com/triggerdotdev/trigger.dev.git |
| octolytics-dimension-user_id | 95297378 |
| octolytics-dimension-user_login | triggerdotdev |
| octolytics-dimension-repository_id | 572570113 |
| octolytics-dimension-repository_nwo | triggerdotdev/trigger.dev |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 572570113 |
| octolytics-dimension-repository_network_root_nwo | triggerdotdev/trigger.dev |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 33c41e9d150e44415272934d676dc63c57d89c3b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width