You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[RFC] queue_job: enqueue dependent job in jobrunner #884
It makes sense for the reasons you mention.
How would the jobrunner identify waiting jobs ready to process, is there any other way than polling?
I'm wondering if we could leverage NOTIFY payloads from the worker that ends a job, so the jobrunner could check only a subset of the jobs.
However, the query plan is not good enough (here I have ~5k jobs in wait_dependencies).
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Index Scan using queue_job__state_index onpublic.queue_job (cost=0.43..156305.69 rows=1170 width=41) (actual time=15.904..925.628 rows=4 loops=1)
Output: queue_job.id, queue_job.uuid
Index Cond: ((queue_job.state)::text='wait_dependencies'::text)
Filter: (NOT (SubPlan 1))
Rows Removed by Filter: 3229
SubPlan 1-> Hash Join (cost=64.81..66.19 rows=1 width=0) (actual time=0.285..0.285 rows=1 loops=3233)
Hash Cond: (parent_uuid.value= (parent_job.uuid)::text)
-> Function Scan onpg_catalog.json_array_elements_text parent_uuid (cost=0.01..1.01 rows=100 width=32) (actual time=0.002..0.003 rows=4 loops=3233)
Output: parent_uuid.value
Function Call: json_array_elements_text(((queue_job.dependencies)::json ->'depends_on'::text))
-> Hash (cost=64.65..64.65 rows=12 width=37) (actual time=0.281..0.281 rows=776 loops=3233)
Output: parent_job.uuid
Buckets: 2048 (originally 1024) Batches: 1 (originally 1) Memory Usage: 116kB
-> Index Scan using queue_job__graph_uuid_index onpublic.queue_job parent_job (cost=0.43..64.65 rows=12 width=37) (actual time=0.013..0.188 rows=776 loops=3233)
Output: parent_job.uuid
Index Cond: ((parent_job.graph_uuid)::text= (queue_job.graph_uuid)::text)
Filter: ((parent_job.state)::text<>'done'::text)
Rows Removed by Filter: 42
Query Identifier: -8629826990232030693
Planning Time: 0.150 ms
Execution Time: 925.659 ms
It would probably be better with a jsonb and an index directly on the depends_on key.
Perhaps, when do both
When a job is done: for each uuid in reverse_depends_on a NOTIFY is sent with the uuid, and ChannelManager.notify now check if it is or not ready to be executed according to the dependencies
A catch-up is added in the loop in case of misses
Maybe the notify is not needed at all
Maybe the first step would be to check if we can have a faster query that finds resolved dependencies using jsonb or another execution plan. Also maybe an index on state = 'wait_dependencies'
There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.
Activity
guewen commentedon Jan 23, 2026
It makes sense for the reasons you mention.
How would the jobrunner identify waiting jobs ready to process, is there any other way than polling?
I'm wondering if we could leverage NOTIFY payloads from the worker that ends a job, so the jobrunner could check only a subset of the jobs.
sbidoul commentedon Jan 23, 2026
The notification payload already has the job uuid.
But thinking about it, it means if the jobrunner misses a
donenotification dependencies will stay waiting. Hm...guewen commentedon Jan 26, 2026
Not 100% sure it is correct, but this query should allow to find the jobs in wait_dependencies, it could be in the jobrunner while loop.
However, the query plan is not good enough (here I have ~5k jobs in wait_dependencies).
It would probably be better with a jsonb and an index directly on the
depends_onkey.Perhaps, when do both
Maybe the notify is not needed at all
Maybe the first step would be to check if we can have a faster query that finds resolved dependencies using jsonb or another execution plan. Also maybe an index on state = 'wait_dependencies'
guewen commentedon Jan 27, 2026
Already better by removing the join on
graph_uuidactually (but not so good)github-actions commentedon Aug 2, 2026
There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.