Sync: fix purge and invalid sync history

fixes #2632
fixes #2627
This commit is contained in:
Thomas Gelf 2022-10-07 12:22:19 +02:00
parent 82269775f4
commit 91ca8065e3
6 changed files with 41 additions and 4 deletions

View File

@ -16,6 +16,9 @@ Please note that a long-standing issue for our Sync Rules has been fixed: with
now been fixed. If in doubt, please **preview** your Sync Rules to make sure,
that they behave as expected.
This release brings a small schema migration, cleaning up invalid Sync history
entries. If in doubt, please create a [database backup](05-Upgrading.md#backup-first) first.
### Fixed issues
* You can find issues and feature requests related to this release on our
[roadmap](https://github.com/Icinga/icingaweb2-module-director/milestone/30?closed=1)
@ -24,6 +27,8 @@ that they behave as expected.
* FIX: sync lower-cased all object names since v1.10 (#2608)
* FIX: sync for Datalist entries has been fixed (#2618)
* FIX: Sync now applied NULL values with merge policy (#2623)
* FIX: Sync created Sync History entries for every preview (#2632)
* FIX: "Purge" stopped working for Sync (#2627)
### UI
* FIX: "Modify" Services via the monitoring module (#2615, #2619)

View File

@ -882,7 +882,10 @@ class Sync
));
}
$this->run->setProperties($runProperties)->store();
$this->run->setProperties($runProperties);
if (!$this->store->getBranch()->isBranch()) {
$this->run->store();
}
$this->notifyResolvers();
if (! $this->store) {
$dba->commit();
@ -891,7 +894,10 @@ class Sync
// Store duration after commit, as the commit might take some time
$this->run->set('duration_ms', (int) round(
(microtime(true) - $this->runStartTime) * 1000
))->store();
));
if (!$this->store->getBranch()->isBranch()) {
$this->run->store();
}
Benchmark::measure('Done applying objects');
} catch (Exception $e) {

View File

@ -0,0 +1,12 @@
DELETE sr.*
FROM sync_run sr
JOIN sync_rule s ON s.id = sr.rule_id
WHERE sr.last_former_activity = sr.last_related_activity
AND s.object_type != 'datalistEntry' AND sr.start_time > '2022-09-21 00:00:00';
DELETE FROM sync_run
WHERE (objects_created + objects_deleted + objects_modified) = 0;
INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (182, NOW());

View File

@ -2439,4 +2439,4 @@ CREATE TABLE branched_icinga_dependency (
INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (180, NOW());
VALUES (182, NOW());

View File

@ -0,0 +1,14 @@
DELETE FROM sync_run AS sr
WHERE EXISTS (
SELECT 1 FROM sync_rule AS s
WHERE s.id = sr.rule_id
AND s.object_type != 'datalistEntry'
AND sr.start_time > '2022-09-21 00:00:00'
) AND sr.last_former_activity = sr.last_related_activity;
DELETE FROM sync_run
WHERE (objects_created + objects_deleted + objects_modified) = 0;
INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (182, NOW());

View File

@ -2778,4 +2778,4 @@ CREATE INDEX branched_dependency_search_object_name ON branched_icinga_dependenc
INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (181, NOW());
VALUES (182, NOW());