Revert "Remove useless and confusing condition in WHERE for UPDATE in QueuedTask"

This reverts commit 622c0f8e866c37cba3ce2000587269fe435e8710.
Split where statement to bit chunks since every id in idlist can have a different timeout