--SQLAlchemy -The Python SQL Toolkit and Object Relational MapperTo 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+...@googlegroups.com.To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/CAOLfK3Ud5spwMWPQTJws4zJixu7FuS5bLTu3OCmpxFLUpYn62A%40mail.gmail.com.
ORM Sessions ride on top of connections, but since the Session under it's default pattern of being bound to an Engine does the "connect" internally, it's probably inconvenient to adapt the optimistic disconnect approach to it. You would probably want to bind the Session to the Connection explicitly.
however, I would advise using pool_pre_ping instead which is much easier to use and has basically no downsides. this feature didn't exist when the docs for "optimistic disconnect" were written.
Hi Mike,Thanks for the reply!On Mon, Jun 7, 2021 at 6:08 PM Mike Bayer <mik...@zzzcomputing.com> wrote:ORM Sessions ride on top of connections, but since the Session under it's default pattern of being bound to an Engine does the "connect" internally, it's probably inconvenient to adapt the optimistic disconnect approach to it. You would probably want to bind the Session to the Connection explicitly.I searched the SA docs, but could not find how to bind the Session to the Connection.
however, I would advise using pool_pre_ping instead which is much easier to use and has basically no downsides. this feature didn't exist when the docs for "optimistic disconnect" were written.Sure. I was only looking at doing the optimistic disconnect because it seemed a little more resilient to failures (if a DB error happens mid transaction) and because I felt I could control the number of retries and put in an exponential backoff.Do you suggest I use the custom pessimistic ping code:to add in exponential backoff or add additional retries?
Thank you again for the help!-m
--SQLAlchemy -The Python SQL Toolkit and Object Relational MapperTo 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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/CAOLfK3WYSinbhQLbMaBTf7sRRDZ8PtVcQ6u2-gV4ftjS36ZstA%40mail.gmail.com.
however, I would advise using pool_pre_ping instead which is much easier to use and has basically no downsides. this feature didn't exist when the docs for "optimistic disconnect" were written.Sure. I was only looking at doing the optimistic disconnect because it seemed a little more resilient to failures (if a DB error happens mid transaction) and because I felt I could control the number of retries and put in an exponential backoff.Do you suggest I use the custom pessimistic ping code:to add in exponential backoff or add additional retries?what's the real-world use case where exponential backoff is useful?
do you expect databases to be shut down for a number of minutes without disabling the application ?
On Tue, Jun 8, 2021 at 10:28 AM Mike Bayer <mik...@zzzcomputing.com> wrote:however, I would advise using pool_pre_ping instead which is much easier to use and has basically no downsides. this feature didn't exist when the docs for "optimistic disconnect" were written.Sure. I was only looking at doing the optimistic disconnect because it seemed a little more resilient to failures (if a DB error happens mid transaction) and because I felt I could control the number of retries and put in an exponential backoff.Do you suggest I use the custom pessimistic ping code:to add in exponential backoff or add additional retries?what's the real-world use case where exponential backoff is useful?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 commandSSL connection has been closed unexpectedly
I don't know exactly what is causing the failure. Our VM guy seems to think it might be a network issue. Either way, I feel the code should retry a few times just to see if the cause of the error goes away.
do you expect databases to be shut down for a number of minutes without disabling the application ?No. I don't know what the timing parameters are of my particular failure. Pre ping doesn't seem like it allows for any sort of length of time before failing.
I don't know if this offers any more clarity to what I'm experiencing and what I'm trying to code around.Thanks again for the help and dialogue!-m
--SQLAlchemy -The Python SQL Toolkit and Object Relational MapperTo 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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/CAOLfK3XEJWahpk9WRCNG%2BHkGGeiM7wR5zgmNeJHG2ECYkk%3Dc0A%40mail.gmail.com.
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 commandSSL connection has been closed unexpectedlyright 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.
--SQLAlchemy -The Python SQL Toolkit and Object Relational MapperTo 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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/CAOLfK3W539EFhaDYAu3A7Gxr3WrwbdCGX12V_Y19gXZz3O74sA%40mail.gmail.com.