bz19866: more fixes for ItemTracker crashes

Fixed it so that we open a transaction before running our initial query for
ItemTracker.  I thought that this was implicitly opened, but I guess not.

Made it so that when connections are released we close any open transaction
by rolling it back.

Emit the will-change signal on ItemTracker before we call
ItemFetcher.refresh_items().
bz19507: Don't put metadata objects into the cache if the insert fails