summaryrefslogtreecommitdiff
path: root/oslo_db/sqlalchemy/session.py
Commit message (Collapse)AuthorAgeFilesLines
* turn on warning-is-error in doc buildDong Ma2017-07-031-2/+2
| | | | Change-Id: I0b64c644f40a2da3242274194d1a5d2858813c25
* Drop use of 'oslo' namespace packageDoug Hellmann2015-06-181-1/+1
| | | | | | | | | | | | | | | | | | | | | The Oslo libraries have moved all of their code out of the 'oslo' namespace package into per-library packages. The namespace package was retained during kilo for backwards compatibility, but will be removed by the liberty-2 milestone. This change removes the use of the namespace package, replacing it with the new package names. The patches in the libraries will be put on hold until application patches have landed, or L2, whichever comes first. At that point, new versions of the libraries without namespace packages will be released as a major version update. Please merge this patch, or an equivalent, before L2 to avoid problems with those library releases. Blueprint: remove-namespace-packages https://blueprints.launchpad.net/oslo-incubator/+spec/remove-namespace-packages Change-Id: Iaf9247f90ba26615d02e5431d6bc98f22351caa7
* Implement new oslo.db.sqlalchemy.enginefacade moduleMike Bayer2015-06-041-792/+82
| | | | | | | | | | | | | | | | | | | | | | | | This module presents a replacement for the EngineFacade system. At the center is the oslo.db.sqlalchemy.enginefacade module, which when imported, provides decorators and context managers which perform all database and ORM connectivity functions transparently. The docstrings as well as the blueprint provide an introduction. The patch includes a refactoring of sqlalchemy/session.py into three dependent modules engines.py, orm.py and enginefacade.py. This is to maintain a non-cyclical import structure as well as to maintain the import behavior of oslo.db overall, as some projects such as glance currently have dependencies on this structure. There is also a slimming down and attempt at modernizing some very old documentation in session.py. The enginefacade system should be preferred moving forward. Implements: blueprint make-enginefacade-a-facade Change-Id: I9a3d0c26bb727eb2c0bd823b9a12fde57cc7c9c3
* Merge "Ensure that create_engine() close test connection"Jenkins2015-05-221-1/+5
|\
| * Ensure that create_engine() close test connectionVictor Sergeyev2015-01-281-1/+5
| | | | | | | | | | | | | | | | | | | | handle_connect_error() open and return a test connection, but nobody uses it in create_engine(), so (depending on Python interpreter) this connection can stay opened in the pool for some time. Co-Authored-By: Roman Podoliaka <rpodolyaka@mirantis.com> Change-Id: Ibef07f0fa1fec61aa10963c07c410a731d7758ef
* | Remove pre-SQLAlchemy-0.9.7 compat utilitiesMike Bayer2015-04-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Now that requirements.txt is at SQLAlchemy 0.9.7 at the minimum, we can remove the engine_connect compatibility module as well as part of the handle_error compatibility module. In particular, this gives us the ability to add and remove engine_connect events using the event API directly which can be handy in test fixtures. Change-Id: I48450ad9d472d4377913ad391a0f5e3ba0f1471f
* | Merge "Implement generic update-on-match feature"Jenkins2015-03-231-0/+22
|\ \
| * | Implement generic update-on-match featureMike Bayer2015-03-051-0/+22
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This feature provides the query.update_on_match() and query.update_returning_pk() methods, as well as the manufacture_persistent_object(), manufacture_entity_criteria(), and manufacture_criteria() utility functions. query.update_on_match() is used to UPDATE a row based on a variety of criteria, and to then return a fully persistent object state representing the row that was matched. It essentially intends to provide an UPDATE that is guaranteed to have matched a specific row in the presence of potential race conditions without using any locking, and to then return a record of that row as if it had been SELECTed. query.update_returning_pk() is a public method that also serves as part of the implementation of query.update_on_match(); this method delivers an UPDATE statement such that the primary key of the single row matched is returned; if zero or multiple rows are matched, and error is raised. To handle this, several backend-specific strategies are provided, which are automatically selected based on the best available. The lowest strategy performs a re-SELECT, but still assumes there's a simple unique column to be queried on, as is currently the use case in Nova (uuid is present). On Postgresql, MySQL and other databases besides SQLite and possibly DB2, more atomic strategies are used. Change-Id: I059f4ae6e72cfa6681a179314144214639f283ef
* | Add process guards + invalidate to the connection poolMike Bayer2015-03-121-0/+33
|/ | | | | | | | | | | | | | | | It's not safe for a database TCP connection to be shared to a child process, as this is a file descriptor which will maintain its state on both sides. Applications such as Cinder which spin up multiprocessing subprocesses at startup time are subject to race conditions as a result. Instead of requiring that engines be explicitly prepared within a child process, we can detect and accommodate this situation in the connection pool itself, by tracking the originating pid of a connection, and if it changes on checkout, by invalidating. Change-Id: If116f7b7140b3eba064d8147e5f637a05beb1cd8
* Update Oslo imports to remove namespace packageDoug Hellmann2015-01-211-1/+1
| | | | | Change-Id: I4ec9b2a310471e4e07867073e9577731ac34027d Blueprint: drop-namespace-packages
* Ensure DBConnectionError is raised on failed revalidateMike Bayer2015-01-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | The second call to connection.scalar() inside of _connect_ping_listener() is not subject to the exc_filters system under SQLAlchemy 0.9 and earlier, in the case that the attempt to revalidate within fails. This causes the exception to be propagated outwards as the original OperationalError (assuming that's what the DBAPI raised, as is typical), rather than it being wrapped again in DBConnectionError. SQLAlchemy 1.0 has altered this behavior such that the handle_error() listener is invoked correctly for revalidiation attempts (it was being invoked before, but without the correct state), as well as for initial connect attempts, as part of https://bitbucket.org/zzzeek/sqlalchemy/issue/3266/. For 0.9 and earlier, we here backport this system into oslo/db/sqlalchemy/compat.py, including that we redefine the connection pool's handler to re-throw the original dbapi.Error instance directly, then move the handling of this error in terms of SQLAlchemy wrapping and events into the Engine and Connection. The approach here works back to SQLAlchemy 0.8, and is conditional based on whether or not SQLAlchemy 1.0 is detected. Change-Id: I455e957b043318a8500909c66cadde53228b52d6
* Move files out of the namespace packageDoug Hellmann2014-12-241-0/+847
Move the public API out of oslo.db to oslo_db. Retain the ability to import from the old namespace package for backwards compatibility for this release cycle. Blueprint: drop-namespace-packages Change-Id: Ie96b482b9fbcb1d85203ad35bb65c1f43e912a44