We have a process that runs within our Magento installation that:
- Bootstraps Magento
- Performs some actions which involve writing to a table in mysql
- Connects to a remote API, which takes a long time to respond (20mins +)
- Attempts to write more information to a table in mysql
The problem is, that due to the long time taken for the remote API to respond, the MySQL server has sometimes 'Gone Away' by the time we attempt to perform step 4. The simplest solution to this is to simply increase the wait_timeout for MySQL, but this feels like a hacky solution.
Is there a way from within Magento to close then reopen the database connection? Or even just force a reconnect after step 3? I tried to dig into it, but the actual instantiation of the connection seems (as with many things in Magento) deeply buried. I'm therefore unsure exactly how I might force a reconnect.