When libdb returns DEADLOCK and backend update function retries
the operation, the target entry is reset to the original shape.
The target entry could be or could not be in the entry cache.
Regardless of the status, the original code just released the
entry with backentry_free before going into the next loop, which
causes the cache error.
This patch checks the status of the entry. If it is in the entry
cache, remove it from the entry cache and add a new entry back to
the cache if necessary. To get the accurate cache status of each
entry, the output argument cache_res to id2entry_add_ext is added.
Additinally, error checking for the conflict value in index_add_mods
was week (curr_attr). This patch is adding the check.