5584f89 backend: minimize redis traffic for looping over pending-jobs

Authored and Committed by praiskup 4 years ago
    backend: minimize redis traffic for looping over pending-jobs
    
    Previously, each item in /backend/pending-jobs/ dict caused several
    queries to redis database.  This caused enormous slowdown when we had
    several thousands of builds in build queue.
    
    The result of unsuccessful VM acquire is now cached for
    "<USER>-<ARCH>-<SANDBOX>" triplet, and within the same loop (aka, within
    processing one fetched pending-jobs dict) we don't try to acquire VM for
    the same triplet anymore.
    
    We also checked whether we couldn't re-attach some worker to existing
    builder machine.  This only ever makes sense after the fresh backend
    restart, and never more.
    
    This complements frontend counterpart in commit 548a9a05e1f2fd1.
    
    Fixes: #902