On Wed, 23 Jan 2019 11:53:25 +0100 Ingeborg Hellemo ingeborg.hellemo@uit.no wrote:
(i.e. `cam.port` is set from `interface.ifname` or `interface.ifdescr`, if present, at the time the cam record is created, and is never updated after its creation).
Ah, I guess this happened because this switch had a case of "Found multiple matching interfaces for Interface" (a failure we see quite often)
What? That sounds like a much more intriguing issue...
and I was rummaging around in the database and deleting interfaces around this time.
A-ha!
Then the next question is how do I fix this (short of deleting everything and begin from scratch...)? Delete from cam table where port is empty?
Unless you find it OK to lose history logs, I wouldn't recommend it :)
But you could potentially backfill those records with the current interface name, if you so cared (and if you trust the ifindexes have not been renumbered since the records were created). You should also take care to only update records from the problematic device or records from within a certain time period.
Something like this, perhaps:
UPDATE cam SET port=ifname FROM interface WHERE interface.netboxid = cam.netboxid AND interface.ifindex = cam.ifindex AND COALESCE(port, '') = '' AND cam.netboxid = <misbehaving_netbox_id> ;
And I would definitely recommend doing it inside a transaction, so you can verify your results before committing (i.e. start with `BEGIN;` and only issue `END;` when you are certain you did the right thing).