Comments (4)
Well that shouldn’t happen! The prune limit is configurable, so as a quick fix you can lower the limit to something like 1000
to prevent timeouts.
The real fix is to set the prune timeout to :infinity
.
from oban.
My previous comment was wrong (not technically, just the wrong approach). The prune_limit
setting was meant to prevent this exact issue, but it wasn't used for the beats table. Now it is!
from oban.
We were seeing this too, but on jobs not beats.
We have ~60MM rows in our jobs table. The prune query wasn't being satisfied by any existing index and taking 20+ minutes.
To speed things up I added the following index:
CREATE INDEX CONCURRENTLY oban_jobs_id_state_index ON oban_jobs (id desc) WHERE state = 'completed' OR state = 'discarded';
Let me know if you think this should be in Oban itself and I can make a PR.
from oban.
We have ~60MM rows in our jobs table. The prune query wasn't being satisfied by any existing index and taking 20+ minutes.
That's a lot of jobs to have sticking around. I can see how the query wasn't working for that without the proper indexes. The limit doesn't help if the query itself isn't fast enough.
My initial instinct is that removing the order by
clause allows a much faster index only scan of the table:
=> explain analyze select id from oban_jobs where state in ('completed', 'discarded') offset 1000 limit 10000;
QUERY PLAN
═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
Limit (cost=52.80..580.00 rows=10000 width=8) (actual time=0.547..5.642 rows=10000 loops=1)
-> Index Only Scan using oban_jobs_queue_state_scheduled_at_id_index on oban_jobs (cost=0.08..38805.29 rows=736073 width=8) (actual time=0.197..4.956 rows=11000 loops=1)
Filter: (state = ANY ('{completed,discarded}'::oban_job_state[]))
Rows Removed by Filter: 37
Heap Fetches: 2854
Planning Time: 0.090 ms
Execution Time: 6.009 ms
(7 rows)
That avoids adding a single purpose index. However, it doesn't help if somebody is doing time based pruning; that requires a different index (or set of indexes) entirely.
Would you mind opening up a new issue to discuss this?
from oban.
Related Issues (20)
- Unclear docs for `perform/1` callback in case of an unhandled exception, exit or throw HOT 1
- Crontab information in Oban jobs (or job-related Telemetry events) HOT 7
- Potential bug: available jobs not being run HOT 4
- (Postgrex.Error) ERROR 42601 (syntax_error) on deploy HOT 1
- Enqueueing a job with a non-serializable value (changeset) causes error HOT 1
- Oban.Pro.Testing - Upgrade from 1.3.2 `ensure_queues_started` "process not alive" HOT 6
- Oban.Pro.Worker Hook Docs HOT 1
- oban_web - `KeyError` in `Oban.Web.Jobs.SortComponent.render/1` HOT 5
- Add `crontab: false` to recommended test config HOT 5
- `FunctionClauseError` in `Registry.keys/2` HOT 2
- `not_null_violation` Postgres error for Oban scheduled job HOT 8
- Config for Oban.Met? Not seen this before from AppSignal HOT 5
- Oban.Pro.Workers.Chain with test inline mode causes Ecto error on comparison with nil id HOT 1
- Oban - Partitioning by worker and args at the same time does not work HOT 2
- with_testing_mode is ignored if enqueuing within another process HOT 1
- DynamicCron cannot insert jobs for Crontab entries that override `guaranteed` HOT 5
- Oban.drain_queue isn't working anymore in test HOT 2
- Oban Pro v1.4 Workflow migration fails on Postgres 13 trigger creation HOT 1
- Tests failing since upgrade from 2.17.7 to 2.17.9 HOT 2
- Test fails when upgrading from 2.17.8 to 2.17.9 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oban.