Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
23 changes: 22 additions & 1 deletion 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];
$unresponsiveServerError = [];
foreach ($servers as $server) {
$headers['Host'] = $server->getHost();
try {
Expand All @@ -131,10 +132,30 @@ private function sendPurgeRequestToServers($socketAdapter, $servers, $formattedT
$socketAdapter->read();
$socketAdapter->close();
} catch (\Exception $e) {
$this->logger->critical($e->getMessage(), compact('server', 'formattedTagsChunk'));
$unresponsiveServerError[] = "Cache host: " . $server->getHost() . ":" . $server->getPort() .
"resulted in error message: " . $e->getMessage();
}
}

$errorCount = count($unresponsiveServerError);

if ($errorCount > 0) {
$loggerMessage = implode(" ", $unresponsiveServerError);

if ($errorCount == count($servers)) {
$this->logger->critical(
'No cache server(s) could be purged ' . $loggerMessage,
compact('server', 'formattedTagsChunk')
);
return false;
}

$this->logger->warning(
'Unresponsive cache server(s) hit' . $loggerMessage,
compact('server', 'formattedTagsChunk')
);
}

$this->logger->execute(compact('servers', 'formattedTagsChunk'));
return true;
}
Expand Down
17 changes: 17 additions & 0 deletions lib/internal/Magento/Framework/Cache/InvalidateLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
use Magento\Framework\App\Request\Http as HttpRequest;
use Psr\Log\LoggerInterface as Logger;

/**
* Invalidate logger cache.
*/
class InvalidateLogger
{
/**
Expand All @@ -34,6 +37,7 @@ public function __construct(HttpRequest $request, Logger $logger)

/**
* Logger invalidate cache
*
* @param mixed $invalidateInfo
* @return void
*/
Expand All @@ -44,6 +48,7 @@ public function execute($invalidateInfo)

/**
* Make extra data to logger message
*
* @param mixed $invalidateInfo
* @return array
*/
Expand All @@ -65,4 +70,16 @@ 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));
}
}