From 9d1eb2d3d9ed3fe850e89bf117a9b160b386178a Mon Sep 17 00:00:00 2001 From: Morten Brekkevold Date: Thu, 30 May 2024 05:49:21 +0000 Subject: [PATCH] Fix incorrect netbox/arp rule deletion 43d5543be92494877c92e082373ceaebd24568e6 deleted the incorrect database rule and made it into a release. This reinstates the rule, ensures data integrity and deletes the *correct* rule: `netbox_status_close_arp` --- changelog.d/2910.fixed.md | 1 + python/nav/models/sql/changes/sc.05.10.0002.sql | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 changelog.d/2910.fixed.md create mode 100644 python/nav/models/sql/changes/sc.05.10.0002.sql diff --git a/changelog.d/2910.fixed.md b/changelog.d/2910.fixed.md new file mode 100644 index 0000000000..c6ecb7fcf9 --- /dev/null +++ b/changelog.d/2910.fixed.md @@ -0,0 +1 @@ +Replace incorrect fix for premature ARP record closure introduced in 5.10.1 \ No newline at end of file diff --git a/python/nav/models/sql/changes/sc.05.10.0002.sql b/python/nav/models/sql/changes/sc.05.10.0002.sql new file mode 100644 index 0000000000..ed6b790fff --- /dev/null +++ b/python/nav/models/sql/changes/sc.05.10.0002.sql @@ -0,0 +1,12 @@ +-- Reinstate rule that closes ARP records on netbox deletion, see #2910 +CREATE OR REPLACE RULE netbox_close_arp AS ON DELETE TO netbox + DO UPDATE arp SET end_time=NOW() + WHERE netboxid=OLD.netboxid AND end_time='infinity'; + +-- Close all open ARP records that have no associated netbox (those that may have been kept open in error due to +-- deletions between 5.10.1 and 5.10.2) +UPDATE arp SET end_time=NOW() + WHERE end_time>='infinity' AND netboxid IS NULL; + +-- Remove actually malfunctioning ARP record closing rule, see #2910 +DROP RULE IF EXISTS netbox_status_close_arp ON netbox;