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']);
.....
}
}
} |