Database metadata performance optimizations

In instance_metadata_update():
Fix bug: there was no transaction in method.
Performance optimization:
let N is number of metadata items.
Was:
*) 1 request to get all (M) existing in DB entries
*) (M-L) requests to get all entries that don't exist in metadata
*) (M-L) requests to soft delete all entries
*) N request to try to get get metadata by key from DB
*) N request to save
Now:
*) 1 requst to soft delete entries that exist in DB and don't exist in metadata
*) 1 requst to get all(L) entries that exist in metadata and DB
*) L request to update all L entries that exist in DB and metadata
*) N-L request to create new entries.
result 1 + 2*(M - L + N) -> 2 + N

In instance_system_metadata_update():
Fix bug: there was no transaction in method.
Same performance situation.

In aggregate_metadata_get:
Fix bug: there was no transaction at all in method.
Performance optimization:
Let N is number of metadata items.
All request have check that Aggregate exist so each time there are 2 request.
Was:
*) 1 + 1 request to get all (M) entries that exist in DB
*) (1 + 1)*(M-L) request to get each entry that exist in DB and doesn't exist in metadata
*) (1 + 1)*(M-L) to soft delete entries
*) N * (1 + 1) try to get each item that exist in metadata
*) N * (1 + 1) update or save
Now:
*) 1 request to get query object if exist Aggregate
*) 1 request to soft delete or entries that exist in DB and doesn't exit in metadata
*) 1 request to get elements that exist in DB and in metadata
*) L request to update existing metadata
*) N - L request to create new metadata
2 + 4*(M - L) + 4*N -> 3 + N

blueprint db-session-cleanup

Change-Id: Ie14f89c567c971dece34cc3659ad3a48cf82acf6
Fix regression in RetryFilter

Fixes regression in RetryFilter.  The RPC layer would convert the list
of tuples that comprised the previously attempted hosts to a list of
lists.  The RetryFilter was attempting to compare a tuple to a list,
which failed.

bug 1096196

Change-Id: I30adf42daf5e86ccec0269eca1f84d06ed4beb59
Merge "Fix regression in RetryFilter"
Merge "Database metadata performance optimizations"