Merge pull request #1836 from Icinga/bugfix/clear-prefetch

Avoid caching between multiple runs of sync
This commit is contained in:
Markus Frosch 2019-04-17 10:59:34 +02:00 committed by GitHub
commit d3fa347ec2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View file

@ -3,6 +3,7 @@
namespace Icinga\Module\Director\Db\Cache;
use Icinga\Module\Director\CustomVariable\CustomVariable;
use Icinga\Module\Director\Data\Db\DbObject;
use Icinga\Module\Director\Db;
use Icinga\Module\Director\Objects\IcingaObject;
use Icinga\Module\Director\Resolver\HostServiceBlacklist;
@ -36,6 +37,7 @@ class PrefetchCache
public static function initialize(Db $db)
{
self::forget();
self::$instance = new static($db);
}
@ -60,6 +62,7 @@ class PrefetchCache
public static function forget()
{
DbObject::clearAllPrefetchCaches();
self::$instance = null;
}

View file

@ -19,6 +19,7 @@ use Icinga\Module\Director\Objects\SyncProperty;
use Icinga\Module\Director\Objects\SyncRule;
use Icinga\Module\Director\Objects\SyncRun;
use Icinga\Exception\IcingaException;
use Icinga\Module\Director\Repository\IcingaTemplateRepository;
use InvalidArgumentException;
class Sync
@ -811,6 +812,8 @@ class Sync
protected function prepareCache()
{
PrefetchCache::initialize($this->db);
IcingaTemplateRepository::clear();
$ruleObjectType = $this->rule->get('object_type');
$dummy = IcingaObject::createByType($ruleObjectType);