Hi internals, There's been some discussion over how to deal with persistent connections in PDO. I know this is a common problem users deal with; sometimes the connection has been put into a bad state (i.e. search paths or some other connection-level state being set by user code), or the PDO liveness check may not be perfect for all drivers (i.e. for PDO_ODBC, it depends heavily on the connection dead attribute implementation in the driver). I've at least acknowledged this as a general problem for persistent resources/objects before (GH-15749). I've seen users cope with bad persistent connections by killing the PHP process running into it, which is obviously not ideal.
There's been some proposals to fix this; mostly by adding a close method to PDO (GH-19933/GH-19214), but this complicates PDO by making closed connection objects a thing. I have a draft PR (GH-21007) that simply provides an attribute for throwing away the current persistent connection and getting a new one; this allows userland code to implement their own reconnect and recovery behaviours. However, I'm still not very sure it's the best approach, as said recovery code is awkward code that users need to implement for themselves. I've thought about some alternatives (i.e. allow hooking liveness checks to supplement with user code), but I haven't implemented those. I'd appreciate some thoughts or proposals on the manner, since this is a papercut that I've seen users deal with. Regards, Calvin GH issues/PRs mentioned: https://github.com/php/php-src/pull/15749 https://github.com/php/php-src/pull/19214 https://github.com/php/php-src/pull/19933 https://github.com/php/php-src/pull/21007
