Sync db with code from oslo

Synced up to:
7a11a04 Automatic retry db.api query if db connection lost

Change-Id: I3cd929bc9a217842960925086be3375ec862688e