candlepin/candlepin — pull request #581 by cakofony (2014-05-09 15:22:16+00:00)
Title: Some preliminary code to avoid deadlock situations

This is not a complete sollution, but does reduce the chances
of deadlocks in the most common places.

Deadlocks may still occur when removing entitlements that
create subpools while subpools are being bound (with other pools)
As well as updating subpools.

We need to lock the source pool before updating derived pools,
which makes enforcing order much harder. We might be able to
get around that by leveraging the "created" date (breaking
ties with id)