Skip to content
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

Changes cache hosts warning / critical levels and continue on multiple hosts #18852

Merged
merged 9 commits into from
Feb 15, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
14 changes: 12 additions & 2 deletions app/code/Magento/CacheInvalidate/Model/PurgeCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ private function splitTags($tagsPattern)
private function sendPurgeRequestToServers($socketAdapter, $servers, $formattedTagsChunk)
{
$headers = [self::HEADER_X_MAGENTO_TAGS_PATTERN => $formattedTagsChunk];
$unresponsiveServerCount = 0;
foreach ($servers as $server) {
$headers['Host'] = $server->getHost();
try {
Expand All @@ -131,10 +132,19 @@ private function sendPurgeRequestToServers($socketAdapter, $servers, $formattedT
$socketAdapter->read();
$socketAdapter->close();
} catch (\Exception $e) {
$this->logger->critical($e->getMessage(), compact('server', 'formattedTagsChunk'));
return false;
$unresponsiveServerCount++;
if ($unresponsiveServerCount == count($servers)) {
wiardvanrij marked this conversation as resolved.
Show resolved Hide resolved
$this->logger->critical('Available cache server(s) are unresponsive: ' . $e->getMessage(), compact('server',
'formattedTagsChunk'));
return false;
} else {
$this->logger->warning('Unresponsive cache server hit, yet more cache servers are available: ' .
$e->getMessage(), compact('server', 'formattedTagsChunk'));
continue;
}
}
}

$this->logger->execute(compact('servers', 'formattedTagsChunk'));
return true;
}
Expand Down
13 changes: 13 additions & 0 deletions lib/internal/Magento/Framework/Cache/InvalidateLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,17 @@ public function critical($message, $params)
{
$this->logger->critical($message, $this->makeParams($params));
}

/**
* Log warning
*
* @param string $message
* @param mixed $params
* @return void
*/
public function warning($message, $params)
{
$this->logger->warning($message, $this->makeParams($params));
}

wiardvanrij marked this conversation as resolved.
Show resolved Hide resolved
}