title: Php mysqli - persistent connections - How to restart/reconnect?
body: <p>I'd like to restart php's mysqli persistent connections.</p>
  <p>Everything I've been able to find about it tends to be about 10 years old and obsolete (e.g. talking about mysqli_ping and mysqli_close).</p>
  <p>Background: We're using a DigitalOcean managed database, with a standby node. If the main database fails or has a problem it automatically switches over to the standby node. But our webserver's php persistent connections are still open and connected to the old database instance and their queries time out. Whenever we encounter a &quot;2006: mysql has gone away&quot; error I'd like to try restarting the persistent connection, so that it uses the standby node as soon as it's available. (I'm using linux, nginx, php8.0, mysql8.0)</p>
  <p>If there's nothing better, would setting MYSQLI_OPT_CONNECT_TIMEOUT to 10 secs mean that if it didn't connect after 10 secs it'd fail AND close the persistent connection? (Meaning that the next connection attempt would create a new persistent connection that would then be to the standby node.) Or would it fail and close the current page's connection, still leaving the persistent connection open to the old database instance?</p>