candlepin/candlepin — pull request #753 by dgoodwin (2014-10-29 18:23:53+00:00)
Title: Fix entity does not exist as row in database error

Previous attempted fix just avoided the problem by not updating attributes if the pool was flagged for deletion. However this missed the fact that the scenario can also occur if the pool attributes change, and entitlements still need to get revoked. (overconsumption)

Seems a flush is recommended to make sure the modified attributes are created in the db, after which we can successfully lock the pool and revoke any entitlements required.

PR also fixes a nasty discovery with the "isOverflowing" check, which was not accounting for unlimited pools. (quantity -1) As it stands now it appears if an unlimited pool was changed in any way during refresh, we'd revoke every entitlement it has.