Is there anyway I can force a reconnect to Mysql with Magento? or Replace the connection entirely?
I have an importer which is slow, and is very custom using Magento models. Before you say it… No I don't want t use any off the shelf products. This is super specific. A way of speeding this up would be to pcntl fork during a part of the application to improve import speed. The issue with pcntl_fork is that the db connection will go bad as soon as you fork. So I need to totally reconnect the Mage core connection so that my forked process is new connection. So any mage core model save will automatically be using the new connection rather that the parent pcntl processes connection.
Ideas?
Cheers
Best Answer
Threading can work, DB connection unterminated:
I'm not having the same issue that you are when I
switch
over$pid
-Returns:
However if I do not, I get a MySQL gone away error:
Summary:
I think you have an error in your execution code somewhere wherein you are not executing database queries from within the switch over process ID.
Edit
Further investigation:
By declaring a
Mage::registry
value, and then inspecting the source of the query we can, from withinlib/Varien/Db/Adapter/Pdo/Mysql.php
, inspect the scope (pid) of the current running process:test.php:
lib/Varien/Db/Adapter/Pdo/Mysql.php:
Result: