Description

See IRC.

With 1M tasks in queue, the query to pull a task off the top of the stack turns into a garbage mess full of tablescans.

Some of the keying assumes more failed tasks than queued tasks. This is technically true on a normal install (perhaps dozens of failed tasks, ~0 queued tasks) but the scale is irrelevant. All realistic installs with more than 100K rows should have 99% of them in queue.