...
Code Block |
---|
|
class FixStuckIndexers
{
public function execute()
{
if ($this->configuration->shouldEnableSuspendedIndexes()) {
$this->fixSuspendedIndexes();
}
if (!$this->configuration->isAutomaticFixingEnabled()) {
return;
}
$thresholdToMarkIndexerAsStuck = $this->configuration->getThresholdToMarkIndexerAsStuck();
$this->fixStuckIndexers($thresholdToMarkIndexerAsStuck);
}
protected function fixSuspendedIndexes()
{
$suspendedMview = $this->mviewState->getSuspendedIndexers() ?? [];
foreach ($suspendedMview as $mview) {
$this->mviewState->setIndexerAsIdle($mview['view_id']);
.....
}
}
protected function fixStuckIndexers($threshold)
{
$stuckMview = $this->mviewState->getStuckIndexers($threshold) ?? [];
foreach ($stuckMview as $mview) {
$this->mviewState->setIndexerAsIdle($mview['view_id']);
.....
}
$stuckFull = $this->indexerState->getStuckIndexers($threshold) ?? [];
foreach ($stuckFull as $indexer) {
$this->indexerState->setIndexerAsInvalid($indexer['indexer_id']);
.....
}
}
} |
MviewState
Get stuck and suspended indexers, also set indexer status as idle
vendor/creativestyle/magesuite-stuck-indexers-fixer/Model/ResourceModel/MviewState.php:14
Code Block |
---|
|
class MviewState
{
public function getStuckIndexers($stuckDetectionThreshold)
{
$connection = $this->resourceConnection->getConnection();
$select = $connection->select();
$select->from($connection->getTableName('mview_state'));
$select->where('status = ?', \Magento\Framework\Mview\View\StateInterface::STATUS_WORKING);
$select->where(sprintf('updated < date_sub(NOW(), INTERVAL %s Minute)', $stuckDetectionThreshold));
return $connection->fetchAll($select);
}
public function getSuspendedIndexers()
{
$connection = $this->resourceConnection->getConnection();
$select = $connection->select();
$select->from($connection->getTableName('mview_state'));
$select->where('status = ?', \Magento\Framework\Mview\View\StateInterface::STATUS_SUSPENDED);
return $connection->fetchAll($select);
}
public function setIndexerAsIdle($viewId)
{
$connection = $this->resourceConnection->getConnection();
return $connection->update(
$connection->getTableName('mview_state'),
['status' => 'idle'],
['view_id = ?' => $viewId]
);
}
} |
Frontend
There are no frontend features in the module.