diff --git a/config/runtime.exs b/config/runtime.exs index 9358b978..d970959c 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -261,8 +261,19 @@ if config_env() == :prod do # causing oban_jobs to bloat to millions of rows and slow all queries. # 50k/5s (10,000/s) keeps the table small. {Oban.Plugins.Pruner, max_age: 60, limit: 50_000, interval: to_timeout(second: 5)}, - # Rescue orphaned jobs (when node crashes) - {Oban.Plugins.Reindexer, schedule: "0 2 * * *"}, + # Rescue orphaned jobs (when node crashes) and prevent index bloat + # High DELETE churn (10k jobs/sec pruned) causes severe index bloat on: + # - Primary key (82.2 bloat, 3.2GB waste) + # - Scheduling index (216.8 bloat, 7.9GB waste) + # REINDEX CONCURRENTLY reclaims space without blocking operations. + {Oban.Plugins.Reindexer, + schedule: "0 2 * * *", + indexes: [ + "oban_jobs_pkey", + "oban_jobs_state_queue_priority_scheduled_at_id_index", + "oban_jobs_args_index", + "oban_jobs_meta_index" + ]}, # Rescue jobs stuck in executing state (mark as cancelled after 10 minutes) {Oban.Plugins.Lifeline, rescue_after: to_timeout(minute: 10)} ]