Remove pending builds from the queue on conflict

Merged Grzegorz Bizon requested to merge fix/gb/pending-builds-resilience into master

What does this MR do and why?

When the new denormalized pending builds table is enabled, database-level consistency guarantees are reduced because of the denormalization.

Here we are improving our resiliency mechanisms by properly reconciling the database state in case of a conflicting data being detected. We remove a queuing entry of a build that has already been processed.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Grzegorz Bizon