Automatic retry db.api query if db connection lost

Current patch allows us to retry db.api method call if
database connection was lost temporally.

It can be done in a such way:
 - We should use annotate all methods which are safe to retry with
   @safe_for_db_retry, if it's totally safe to retry these functions
 - And we must allow db-retry feature in config (`use_db_reconnect` option
   in a `database` group). It's will allow db-retry for all db.api
   methods.

If function suppose to be retried and it's got `db-gone-away` error,
it's will calls in a loop until it succeeds, or until maximum retries
count will be reached.
Maximum retries count and timeout between retries attempts are configurable.

We use SQLA engine.dialect.is_disconnect() function to determine
broken db connection so it's should work for all supported SQLA
backends (MySQL, PostgreSQL, DB2 and SQLite supported as well).

Added wrapper for session and query methods. This wrapper catch
exceptions caused by broken db connection and re-raise it as
DBConnectionError exception.

Note, that it's safely to use db-retry feature only if all db.api
queries use single transaction.

At the moment this feature is experimental, so disabled by default.

Previous attepmt - https://review.openstack.org/#/c/10797/
'Proof-of-concept' patch in Nova https://review.openstack.org/#/c/35610/

blueprint db-reconnect

Co-authored-by: Devananda van der Veen <devananda.vdv@gmail.com>

Change-Id: Ifd848ea70a62fb9f7ccbc8bfd22a10ab9d3135c9
Merge "Automatic retry db.api query if db connection lost"