The use of plain SQLAlchemy create_engine in Zaqar bypasses
lots of oslo_db features that are associated with its
version of create_engine, some useful and some critical.
Among favorable behaviors that are added:
* The SQLite PRAGMA FOREIGN KEYS call is abstracted into the
sqlite_fk flag
* The engine is given a pessimistic "ping" event, which emits
a "SELECT 1" upon connection checkout which will then recycle
the connection if the backing database is no longer connected.
As we are using a connection pool, if the database has been
restarted, or in the case of MySQL a default timeout of eight
hours idle has passed, existing pooled connections will be stale.
Upcoming SQLAlchemy 1.2 includes this feature as a simple flag
but for now, oslo_db implements the event listener as directed
by SQLA docs
* The errors raised by the DBAPI, and then wrapped by SQLAlchemy,
are further sub-classified. In particular, Zaqar seems to use
a lot of IntegrityError catches to detect duplicate entry and
foreign key constraint conditions. oslo_db parses these out on
a per-database-basis into individual DBDuplicateEntry,
DBReferenceError, and other error classes, allowing Zaqar to
respond specifically to the sub-class of IntegrityError or
allow it to propagate if the condition is unhandled.
* checks for MySQL SQL_MODE and best practice driver (pymysql)
will emit warnings if these conditions are not met.
* Gets Zaqar ready for further oslo.db integration and guides
new features into oslo_db, including a potential "mysql timezone"
setting
Change-Id: I16c3ed89e006e132bbd0295be1dfd0b561b2037c
Resolves-bug: https://bugs.launchpad.net/tripleo/+bug/1691951
The sqlalchemy driver uses a run() wrapper instead of directly
using the connection.execute() method. I changed the other use
of connection.execute() to run() for consistency.
Closes-Bug: #1469207
Change-Id: I0cfe043f31e8bebe26c983c734e0db754e122fbe
Some controllers in the sqlalchemy driver were creating connections in
their constructors. This, besides creating a connection when it's not
needed, ended up creating such connection in the wrong thread.
The above is an issue when using sqlite or non-thread-safe drivers since
the connection would be shared accross different threads when running
under scalable wsgi containers.
This patch moves the connection back to being lazy.
Change-Id: I4b45ad1b20b81962a56536fd875d165072493ade
Bring back the sqlalchemy unittests and fix all the bugs required to
make the tests pass.
Closes-bug: #1490450
Change-Id: Ibfa1a3ff372ce3e4a98a532798113013d3c1dec1
Given we are going to implement notification, so the 'queues'
package is not suitable for current scope of zaqar. This
patch will remove the 'queues' package.
Partially implements: blueprint notifications
Change-Id: I6984f31f4bd1e646b585c45c088ed239b58587c4