Invalid SessionHandle: SessionHandle [...]
This is not the same as #160 as the error message is slightly different and the fix for that does not work. This happens well before an hour or any timeout could be reached (I've seen it within minutes of starting our backend locally before). It looks like there are other situations where this can happen besides a timeout.
My understanding is that the sqlalchemy dialect should let sqlalchemy know to invalidate the connection rather than just failing/erroring (e.g. see here), though I don't know enough to understand the correct way to do that. Based on the sqlalchemy documentation,it sounds like the pre-ping is dialect-specific. Not sure if that needs to be changed or something else. The sqlalchemy documentation has an example for handling specific errors as disconnects, but it's only for sqlalchemy 2.0, so that's not really useful here.