On Tue, Jun 8, 2021 at 11:58 AM Mike Bayer <mike...@zzzcomputing.com> wrote:
> > Unknown network failures, I suppose. I have an application that is > throwing an exception right now due to: > > psycopg2.OperationalError: terminating connection due to administrator > command > SSL connection has been closed unexpectedly > > > right so if that happens on a connection that's been sitting in the pool > when you first go to use it, pre_ping will solve that. > Okay. That sounds pretty good. I've turned on logging (at the DEBUG level) per... https://docs.sqlalchemy.org/en/14/core/engines.html#dbengine-logging and I am trying to force an invalid connection by: while True: # read stdin o = SQLObject(something_from_stdin) session.add(o) session.commit() # Go to DB server and restart postgresql However I don't see any indication that the pre_ping invalidated a connection... # Here is the first commit from SA... INFO:sqlalchemy.engine.base.Engine:select version() INFO:sqlalchemy.engine.base.Engine:{} DEBUG:sqlalchemy.engine.base.Engine:Col ('version',) DEBUG:sqlalchemy.engine.base.Engine:Row ('PostgreSQL 12.4 (Debian 12.4-3) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.0-13) 10.2.0, 64-bit',) INFO:sqlalchemy.engine.base.Engine:select current_schema() INFO:sqlalchemy.engine.base.Engine:{} DEBUG:sqlalchemy.engine.base.Engine:Col ('current_schema',) DEBUG:sqlalchemy.engine.base.Engine:Row ('public',) INFO:sqlalchemy.engine.base.Engine:SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1 INFO:sqlalchemy.engine.base.Engine:{} INFO:sqlalchemy.engine.base.Engine:SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1 INFO:sqlalchemy.engine.base.Engine:{} INFO:sqlalchemy.engine.base.Engine:show standard_conforming_strings INFO:sqlalchemy.engine.base.Engine:{} DEBUG:sqlalchemy.engine.base.Engine:Col ('standard_conforming_strings',) DEBUG:sqlalchemy.engine.base.Engine:Row ('on',) INFO:sqlalchemy.engine.base.Engine:BEGIN (implicit) INFO:sqlalchemy.engine.base.Engine:INSERT INTO call_records (inserted_at, acct_code, vdn) VALUES (%(inserted_at)s, %(acct_code)s, %(vdn)s) RETURNING call_records.id INFO:sqlalchemy.engine.base.Engine:{'inserted_at': 'now', 'acct_code': 'yuy', 'vdn': 'tyt'} DEBUG:sqlalchemy.engine.base.Engine:Col ('id',) DEBUG:sqlalchemy.engine.base.Engine:Row (18,) INFO:sqlalchemy.engine.base.Engine:COMMIT # DB restarted and the second pass through the while loop... INFO:sqlalchemy.engine.base.Engine:BEGIN (implicit) INFO:sqlalchemy.engine.base.Engine:INSERT INTO call_records (inserted_at, acct_code, vdn) VALUES (%(inserted_at)s, %(acct_code)s, %(vdn)s) RETURNING call_records.id INFO:sqlalchemy.engine.base.Engine:{'inserted_at': 'now', 'acct_code': '909', 'vdn': '909'} DEBUG:sqlalchemy.engine.base.Engine:Col ('id',) DEBUG:sqlalchemy.engine.base.Engine:Row (19,) INFO:sqlalchemy.engine.base.Engine:COMMIT Should I be seeing something in the logs about an invalidated connection? Or am I not forcing an invalid connection correctly? Thanks for the feedback! -m -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/CAOLfK3W539EFhaDYAu3A7Gxr3WrwbdCGX12V_Y19gXZz3O74sA%40mail.gmail.com.