Skip to content

Make the MySQL connection disconnect/reconnect feature configurable (default: off) #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ IntegerNet_Solr Free for Magento 1
===============
Release Notes

Upcoming
---------------

- Make the MySQL connection disconnect/reconnect feature configurable (default: off)

Version 1.7.4 (Jul 17, 2017)
---------------

Expand Down
13 changes: 12 additions & 1 deletion src/app/code/community/IntegerNet/Solr/Model/Resource/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,26 @@ class IntegerNet_Solr_Model_Resource_Db
*/
public function disconnectMysql()
{
if (!Mage::getStoreConfigFlag('integernet_solr/indexing/disconnect_mysql_connections')) {
return;
}

/** @var $coreResource Mage_Core_Model_Resource */
$coreResource = Mage::getSingleton('core/resource');
if (!method_exists($coreResource, 'getConnections')) {
return; // method only exists from Magento CE 1.9.1 / EE 1.14.1
}

/** @var Zend_Db_Adapter_Abstract $connection */
foreach (Mage::getSingleton('core/resource')->getConnections() as $name => $connection) {
foreach ($coreResource->getConnections() as $name => $connection) {
if ($connection instanceof Zend_Db_Adapter_Abstract) {
if ($this->isTransactionOpen($connection)) {
continue;
}
$connection->closeConnection();
}
}

// connections (adapter objects) must be fully reinitialized, otherwise initStatements are not executed
Mage::unregister('_singleton/core/resource');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

/**
* @loadFixture registry
* @loadFixture config
* @doNotIndexAll
*/
class IntegerNet_Solr_Test_Model_Resource_Db extends EcomDev_PHPUnit_Test_Case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ config:
default/integernet_solr/server/http_method: curl
default/integernet_solr/server/use_https: 0
default/integernet_solr/server/use_http_basic_auth: 0
default/integernet_solr/indexing/disconnect_mysql_connections: 1
default/integernet_solr/connection_check/is_active: 1
default/integernet_solr/fuzzy/is_active: 0
default/integernet_solr/category/is_active: 1
Expand Down
1 change: 1 addition & 0 deletions src/app/code/community/IntegerNet/Solr/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
<indexing>
<pagesize>1000</pagesize>
<delete_documents_before_indexing>1</delete_documents_before_indexing>
<disconnect_mysql_connections>0</disconnect_mysql_connections>
</indexing>
<fuzzy>
<is_active>1</is_active>
Expand Down
12 changes: 11 additions & 1 deletion src/app/code/community/IntegerNet/Solr/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</swap_cores>
<swap_core translate="label,comment">
<swap_core translate="label">
<label>Name of Core to swap active Core with</label>
<frontend_type>text</frontend_type>
<sort_order>40</sort_order>
Expand All @@ -204,6 +204,16 @@
<swap_cores>1</swap_cores>
</depends>
</swap_core>
<disconnect_mysql_connections translate="label,comment">
<label>Disconnect and reconnect MySQL Connections during indexing</label>
<comment>Use this to avoid SQL timeout errors during indexing. Only available since Magento CE 1.9.1 / EE 1.14.1.</comment>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>50</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>0</show_in_website>
<show_in_store>0</show_in_store>
</disconnect_mysql_connections>
</fields>
</indexing>

Expand Down
4 changes: 3 additions & 1 deletion src/app/locale/de_DE/IntegerNet_Solr.csv
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,6 @@
"Show category filter","Kategorie-Filter anzeigen"
"Show products which are out of stock","Produkte anzeigen, die nicht auf Lager sind"
"Solr Priority Multiplier for Products being out of Stock","Solr-Prioritäts-Multiplikator für ausverkaufte Produkte"
"0 = don't show at all, 1 = don't modify, anything between = lower priority","0 = gar nicht anzeigen, 1 = wie Produkte auf Lager, alles dazwischen = niedrigere Priorität"
"0 = don't show at all, 1 = don't modify, anything between = lower priority","0 = gar nicht anzeigen, 1 = wie Produkte auf Lager, alles dazwischen = niedrigere Priorität"
"Disconnect and reconnect MySQL Connections during indexing","MySQL-Verbindungen während der Indizierung trennen und neu aufbauen"
"Use this to avoid SQL timeout errors during indexing. Only available since Magento CE 1.9.1 / EE 1.14.1.","Aktivieren Sie diese Option, wenn Sie Timeout-Fehler während der Indizierung erhalten. Verfügbar erst ab Magento CE 1.9.1 / EE 1.14.1."