Fix #2010 - add protection code for some storeconfig corruption
This patch adds a more robust and self-healing storedconfig in case
of logically corrupted database as the one in #2010 (where multiple
resources of same references are present in the database for the
same host).
The problem is that the resources are stored in a hash with the resource
ref as the key, so we collapse resource of different id but same
reference. The patch fixed this by using a hash by resource id, and
maintaining a list of old extraneous resource in the db that are removved
after the storeconfig pass.
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>