Skip to content

Commit ef2a3dd

Browse files
author
Stanislav Idolov
committed
Merge remote-tracking branch 'origin/indexers' into stock_indexer_batching
2 parents aae3d44 + 01da000 commit ef2a3dd

File tree

9 files changed

+25
-9
lines changed

9 files changed

+25
-9
lines changed

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/BatchSizeCalculator.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
namespace Magento\Catalog\Model\ResourceModel\Product\Indexer\Price;
88

9+
/**
10+
* Ensure that size of index MEMORY table is enough for configured rows count in batch.
11+
*/
912
class BatchSizeCalculator
1013
{
1114
/**

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/CompositeProductRowSizeEstimator.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
use Magento\Framework\Indexer\IndexTableRowSizeEstimatorInterface;
1010

11+
/**
12+
* Estimate index memory size for largest composite product in catalog.
13+
*/
1114
class CompositeProductRowSizeEstimator implements IndexTableRowSizeEstimatorInterface
1215
{
1316
/**

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/IndexTableRowSizeEstimator.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
namespace Magento\Catalog\Model\ResourceModel\Product\Indexer\Price;
88

9+
/**
10+
* Estimate index memory size for simple product.
11+
* Size depends on websites and customer groups count.
12+
*/
913
class IndexTableRowSizeEstimator implements \Magento\Framework\Indexer\IndexTableRowSizeEstimatorInterface
1014
{
1115
/**

app/code/Magento/Catalog/etc/di.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
<preference for="Magento\Catalog\Api\SpecialPriceInterface" type="Magento\Catalog\Model\ResourceModel\Product\Price\SpecialPrice" />
6464
<preference for="Magento\Catalog\Model\ProductIdLocatorInterface" type="Magento\Catalog\Model\ProductIdLocator" />
6565
<preference for="Magento\Framework\Indexer\BatchProviderInterface" type="Magento\Framework\Indexer\BatchProvider" />
66-
<preference for="Magento\Framework\Indexer\BatchSizeCalculatorInterface" type="Magento\Framework\Indexer\BatchSizeCalculator" />
6766
<type name="Magento\Customer\Model\ResourceModel\Visitor">
6867
<plugin name="catalogLog" type="Magento\Catalog\Model\Plugin\Log" />
6968
</type>
@@ -928,12 +927,12 @@
928927
</type>
929928
<virtualType name="Magento\Catalog\Model\Indexer\Price\CompositeProductBatchSizeManagement" type="Magento\Framework\Indexer\BatchSizeManagement">
930929
<arguments>
931-
<argument name="rowSizeEstimator" xsi:type="object" shared="false">Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\CompositeProductRowSizeEstimator</argument>
930+
<argument name="rowSizeEstimator" xsi:type="object">Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\CompositeProductRowSizeEstimator</argument>
932931
</arguments>
933932
</virtualType>
934933
<virtualType name="Magento\Catalog\Model\Indexer\Price\BatchSizeManagement" type="Magento\Framework\Indexer\BatchSizeManagement">
935934
<arguments>
936-
<argument name="rowSizeEstimator" xsi:type="object" shared="false">Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\IndexTableRowSizeEstimator</argument>
935+
<argument name="rowSizeEstimator" xsi:type="object">Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\IndexTableRowSizeEstimator</argument>
937936
</arguments>
938937
</virtualType>
939938
<virtualType name="Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\FrontendResource" type="Magento\Indexer\Model\ResourceModel\FrontendResource">

app/code/Magento/Indexer/Setup/UpgradeSchema.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
2222
{
2323
$setup->startSetup();
2424

25-
if (version_compare($context->getVersion(), '2.2.0', '<')) {
25+
if (version_compare($context->getVersion(), '2.1.0', '<')) {
2626
$this->addTableSuffixColumn($setup);
2727
}
2828
$setup->endSetup();

app/code/Magento/Indexer/etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9-
<module name="Magento_Indexer" setup_version="2.2.0">
9+
<module name="Magento_Indexer" setup_version="2.1.0">
1010
<sequence>
1111
<module name="Magento_Store"/>
1212
<module name="Magento_AdminNotification"/>

lib/internal/Magento/Framework/Indexer/BatchSizeManagement.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
namespace Magento\Framework\Indexer;
88

9+
/**
10+
* Class set MEMORY table size for indexer processes according batch size and index row size.
11+
*/
912
class BatchSizeManagement implements \Magento\Framework\Indexer\BatchSizeManagementInterface
1013
{
1114
/**
@@ -28,14 +31,13 @@ public function __construct(
2831
*/
2932
public function ensureBatchSize(\Magento\Framework\DB\Adapter\AdapterInterface $connection, $batchSize)
3033
{
31-
// Calculate memory table size for product
32-
$memoryForLargeComposite = $this->rowSizeEstimator->estimateRowSize();
34+
$rowMemory = $this->rowSizeEstimator->estimateRowSize();
3335

3436
$maxHeapTableSize = $connection->fetchOne('SELECT @@max_heap_table_size;');
3537
$tmpTableSize = $connection->fetchOne('SELECT @@tmp_table_size;');
3638
$maxMemoryTableSize = min($maxHeapTableSize, $tmpTableSize);
3739

38-
$size = (int) ($memoryForLargeComposite * $batchSize);
40+
$size = (int) ($rowMemory * $batchSize);
3941

4042
if ($maxMemoryTableSize < $size) {
4143
$connection->query('SET SESSION tmp_table_size = ' . $size . ';');

lib/internal/Magento/Framework/Indexer/BatchSizeManagementInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
/**
1111
* Batch size manager can be used to ensure that MEMORY table has enough memory for data in batch.
12+
* @api
1213
*/
1314
interface BatchSizeManagementInterface
1415
{

lib/internal/Magento/Framework/Indexer/IndexTableRowSizeEstimatorInterface.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@
66

77
namespace Magento\Framework\Indexer;
88

9+
/**
10+
* Calculate memory size for entity according different dimensions.
11+
* @api
12+
*/
913
interface IndexTableRowSizeEstimatorInterface
1014
{
1115
/**
12-
* Calculate memory size for product row.
16+
* Calculate memory size for entity row.
1317
*
1418
* @return float
1519
*/

0 commit comments

Comments
 (0)