Skip to content

Commit 9ea11e7

Browse files
authored
Include semaphore to reset stats expiry to 0 only once
1 parent b358a52 commit 9ea11e7

File tree

1 file changed

+18
-1
lines changed
  • app/code/core/Mage/ImportExport/Model/Resource/Helper

1 file changed

+18
-1
lines changed

app/code/core/Mage/ImportExport/Model/Resource/Helper/Mysql4.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ class Mage_ImportExport_Model_Resource_Helper_Mysql4 extends Mage_Core_Model_Res
2727
public const DB_MAX_PACKET_SIZE = 1048576; // Maximal packet length by default in MySQL
2828
public const DB_MAX_PACKET_COEFFICIENT = 0.85; // The coefficient of useful data from maximum packet length
2929

30+
/**
31+
* Semaphore to disable schema stats only once
32+
*/
33+
private static boolean $instantInformationSchemaStatsExpiry = false;
34+
3035
/**
3136
* Returns maximum size of packet, that we can send to DB
3237
*
@@ -49,11 +54,23 @@ public function getMaxDataSize()
4954
public function getNextAutoincrement($tableName)
5055
{
5156
$adapter = $this->_getReadAdapter();
52-
$adapter->query('SET information_schema_stats_expiry = 0;');
57+
$this->setInformationSchemaStatsExpiry();
5358
$entityStatus = $adapter->showTableStatus($tableName);
5459
if (empty($entityStatus['Auto_increment'])) {
5560
Mage::throwException(Mage::helper('importexport')->__('Cannot get autoincrement value'));
5661
}
5762
return $entityStatus['Auto_increment'];
5863
}
64+
65+
/**
66+
* Set information_schema_stats_expiry to 0 if not already set.
67+
*/
68+
public function setInformationSchemaStatsExpiry()
69+
{
70+
if (!self::$instantInformationSchemaStatsExpiry) {
71+
// Set information_schema_stats_expiry to 0
72+
$this->getReadAdapter()->query('SET information_schema_stats_expiry = 0;');
73+
self::$instantInformationSchemaStatsExpiry = true;
74+
}
75+
}
5976
}

0 commit comments

Comments
 (0)