Module replacements will sometimes crash ipdevpoll inventory job with IntegrityError

Bug #1526282 reported by Morten Brekkevold
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Network Administration Visualized
Fix Released
High
Morten Brekkevold
4.3
Won't Fix
High
Morten Brekkevold
4.4
Fix Released
High
Morten Brekkevold

Bug Description

Under certain circumstances, the ipdevpoll inventory job will crash with a database IntegrityError if a module has been replaced inside a chassis.

The problem seems to be mainly caused by keeping old modules/devices with serial numbers around with a "gone_since" timestamp, to safeguard against deleting entities that only have stopped working temporarily.

Missing devices whose entPhysIndex is being re-used should probably be deleted outright.

Traceback example from ipdevpoll.log:

2015-12-13 06:50:15,395 [ERROR jobs.jobhandler] [statuscheck example-gsw.example.org] Caught exception during save. Last manager = EntityManager(<class 'nav.ipdevpoll.shadows.entity.NetboxEntity'>, 'ContainerRepository'(...)). Last model = <class 'nav.ipdevpoll.shadows.entity.NetboxEntity'>
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/nav/ipdevpoll/jobs.py", line 414, in perform_save
    manager.save()
  File "/usr/lib/python2.7/dist-packages/django/db/transaction.py", line 224, in inner
    return func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/nav/ipdevpoll/shadows/entity.py", line 49, in save
    self._delete_missing()
  File "/usr/lib/python2.7/dist-packages/nav/ipdevpoll/shadows/entity.py", line 86, in _delete_missing
    self._verify_stack_degradation(to_set_missing)
  File "/usr/lib/python2.7/dist-packages/django/db/transaction.py", line 224, in inner
    return func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/django/db/transaction.py", line 218, in __exit__
    self.exiting(exc_value, self.using)
  File "/usr/lib/python2.7/dist-packages/nav/ipdevpoll/db.py", line 90, in exiting
    transaction.commit(using=using)
  File "/usr/lib/python2.7/dist-packages/django/db/transaction.py", line 153, in commit
    connection.commit()
  File "/usr/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 234, in commit
    self._commit()
  File "/usr/lib/python2.7/dist-packages/django/db/backends/postgresql_psycopg2/base.py", line 235, in _commit
    return self.connection.commit()
IntegrityError: duplicate key value violates unique constraint "netboxentity_netboxid_source_index_unique"
DETAIL: Key (netboxid, source, index)=(224, ENTITY-MIB, 3017) already exists.

Changed in nav:
milestone: none → 4.3.4
milestone: 4.3.4 → none
Revision history for this message
Morten Brekkevold (mbrekkevold) wrote :
Revision history for this message
Morten Brekkevold (mbrekkevold) wrote :

and merged to 4.4 as part of this merge: https://nav.uninett.no/hg/default/rev/06c444dd1842

Changed in nav:
status: In Progress → Fix Committed
Changed in nav:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.