Skip to content

Conversation

@jpcuevaslavin
Copy link

@jpcuevaslavin jpcuevaslavin commented Aug 7, 2020

This prevents a -single- worker from taking all jobs.

The subquery should return a row using LIMIT 1. But, it sometimes return multiple rows. Why?
Because the planner may choose to generate a plan that executes a nested loop over the LIMITing subquery, causing more UPDATEs than LIMIT.

The solution is to materialize the selection into a CTE.

fixes collectiveidea/delayed_job#915
fixes #143

see detailed explanation

credits to @koshigoe and @fsateler.

The planner may choose to generate a plan that executes a nested loop over the LIMITing subquery, causing more UPDATEs than LIMIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reserving jobs hits Postgresq Update..(subquery ..limit 1) bug Single worker picks up all jobs

1 participant