summaryrefslogtreecommitdiff
path: root/oslo_db/sqlalchemy/compat
diff options
context:
space:
mode:
authorStephen Finucane <stephenfin@redhat.com>2023-03-22 11:15:16 +0000
committerStephen Finucane <stephenfin@redhat.com>2023-04-06 14:55:03 +0100
commit64e50494f219b5c06ed79f947c91cdb7f37cb0d6 (patch)
tree17d46fb0d71c19c209ffc84b6106792e3eb3e905 /oslo_db/sqlalchemy/compat
parent1f003bcb0b74cecbfe24f52402328b76a07c9983 (diff)
downloadoslo-db-64e50494f219b5c06ed79f947c91cdb7f37cb0d6.tar.gz
Use SQLAlchemy native pre-ping
This functionality has been available upstream since SQLALchemy 1.2 [1]. However, for oslo.db to use this feature while maintaining full behavior, we need at least SQLAlchemy 2.0.5 to provide complete event support. In particular, oslo.db adds several new "is disconnect" conditions including those specific to Galera. Behavior of the handle_error event is modified to expect the "pre-ping" calling form, which may not have an "engine" present (only a dialect), and additionally takes advantage of the new is_pre_ping attribute which informs on the correct way to affect the disconnection status within the ping handler. Change-Id: I50d862d3cbb126987a63209795352c6e801ed919
Diffstat (limited to 'oslo_db/sqlalchemy/compat')
-rw-r--r--oslo_db/sqlalchemy/compat/__init__.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/oslo_db/sqlalchemy/compat/__init__.py b/oslo_db/sqlalchemy/compat/__init__.py
index 6713696..d209207 100644
--- a/oslo_db/sqlalchemy/compat/__init__.py
+++ b/oslo_db/sqlalchemy/compat/__init__.py
@@ -18,6 +18,8 @@ from sqlalchemy import __version__
_vers = versionutils.convert_version_to_tuple(__version__)
sqla_2 = _vers >= (2, )
+native_pre_ping_event_support = _vers >= (2, 0, 5)
+
def dialect_from_exception_context(ctx):
if sqla_2: