SeedDB crashes on unknown IntegrityErrors during delete

Bug #678436 reported by Steinar Otto Sjøholt
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Network Administration Visualized
Fix Released
Medium
Morten Brekkevold

Bug Description

NAV 3.7.0 crashes with the following error message when I try to delete an IP device (type SRV):
I should add that other SRV-entries deletes ok, but this one had it's IP-address changed...

---------------------
MOD_PYTHON ERROR

ProcessId: 16473
Interpreter: 'nav'

ServerName: 'nav'
DocumentRoot: '/usr/share/nav/htdocs'

URI: '/seeddb/netbox/edit'
Location: None
Directory: '/usr/share/nav/htdocs/seeddb/'
Filename: '/usr/share/nav/htdocs/seeddb/netbox'
PathInfo: '/edit'

Phase: 'PythonHandler'
Handler: 'seeddb'

Traceback (most recent call last):

  File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch
    default=default_handler, arg=req, silent=hlist.silent)

  File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1229, in _process_target
    result = _execute_target(config, req, object, arg)

  File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1128, in _execute_target
    result = object(arg)

  File "/usr/share/nav/htdocs/seeddb/seeddb.py", line 165, in handler
    output = editPage(req,pageList[table](),request,unicodeError)

  File "/usr/share/nav/htdocs/seeddb/seeddb.py", line 461, in editPage
    status = page.delete(selected,status)

  File "/usr/share/nav/htdocs/seeddb/seeddb.py", line 1617, in delete
    error += '%s is referenced in another table' % (self.name,)

AttributeError: pageNetbox instance has no attribute 'name'

MODULE CACHE DETAILS

Accessed: Mon Nov 22 10:38:25 2010
Generation: 4

_mp_fee3cb79bb902d1ae2e8fe8693adcb2a {
  FileName: '/usr/share/nav/htdocs/seeddb/initBox.py'
  Instance: 1
  Generation: 1
  Modified: Tue Nov 16 15:23:15 2010
  Imported: Mon Nov 22 09:37:55 2010
}

_mp_79759e91aa07f55e2ec9feb06dcdae38 {
  FileName: '/usr/share/nav/htdocs/seeddb/options.py'
  Instance: 1
  Generation: 2
  Modified: Tue Nov 16 15:23:15 2010
  Imported: Mon Nov 22 09:37:55 2010
}

_mp_ee36530af65736d4598346489c0aee92 {
  FileName: '/usr/share/nav/htdocs/seeddb/seeddb.py'
  Instance: 1
  Generation: 4
  Modified: Tue Nov 16 15:23:15 2010
  Imported: Mon Nov 22 09:37:55 2010
  Children: '/usr/share/nav/htdocs/seeddb/initBox.py',
                '/usr/share/nav/htdocs/seeddb/options.py',
                '/usr/share/nav/htdocs/seeddb/seeddbSQL.py'
}

_mp_6075681fed6c7055dc97214a475ff87e {
  FileName: '/usr/share/nav/htdocs/seeddb/seeddbSQL.py'
  Instance: 1
  Generation: 3
  Modified: Tue Nov 16 15:23:15 2010
  Imported: Mon Nov 22 09:37:55 2010
}

Tags: 3.7.0 seeddb srv
Revision history for this message
Steinar Otto Sjøholt (ssj) wrote :

What I did was to add an IP device - IP-address 192.168.1.10, type SRV. I later changed this to 192.168.1.11.
When I now add a new entry with the original IP-address (192.168.1.10), I get this error:

MOD_PYTHON ERROR

ProcessId: 16467
Interpreter: 'nav'

ServerName: 'nav'
DocumentRoot: '/usr/share/nav/htdocs'

URI: '/seeddb/netbox/predefined'
Location: None
Directory: '/usr/share/nav/htdocs/seeddb/'
Filename: '/usr/share/nav/htdocs/seeddb/netbox'
PathInfo: '/predefined'

Phase: 'PythonHandler'
Handler: 'seeddb'

Traceback (most recent call last):

  File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch
    default=default_handler, arg=req, silent=hlist.silent)

  File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1229, in _process_target
    result = _execute_target(config, req, object, arg)

  File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1128, in _execute_target
    result = object(arg)

  File "/usr/share/nav/htdocs/seeddb/seeddb.py", line 165, in handler
    output = editPage(req,pageList[table](),request,unicodeError)

  File "/usr/share/nav/htdocs/seeddb/seeddb.py", line 451, in editPage
    outputForm,action)

  File "/usr/share/nav/htdocs/seeddb/seeddb.py", line 2402, in add
    function)

  File "/usr/share/nav/htdocs/seeddb/seeddb.py", line 566, in insertNetbox
    ('netboxid','netbox_netboxid_seq'))

  File "/usr/share/nav/htdocs/seeddb/seeddbSQL.py", line 152, in addEntryFields
    executeSQL([sql])

  File "/usr/share/nav/htdocs/seeddb/seeddbSQL.py", line 34, in executeSQL
    database.execute(sql)

IntegrityError: duplicate key value violates unique constraint "netbox_ip_key"

MODULE CACHE DETAILS

Accessed: Mon Nov 22 10:58:20 2010
Generation: 4

_mp_fee3cb79bb902d1ae2e8fe8693adcb2a {
  FileName: '/usr/share/nav/htdocs/seeddb/initBox.py'
  Instance: 1
  Generation: 1
  Modified: Tue Nov 16 15:23:15 2010
  Imported: Mon Nov 22 09:26:32 2010
}

_mp_79759e91aa07f55e2ec9feb06dcdae38 {
  FileName: '/usr/share/nav/htdocs/seeddb/options.py'
  Instance: 1
  Generation: 2
  Modified: Tue Nov 16 15:23:15 2010
  Imported: Mon Nov 22 09:26:32 2010
}

_mp_ee36530af65736d4598346489c0aee92 {
  FileName: '/usr/share/nav/htdocs/seeddb/seeddb.py'
  Instance: 1
  Generation: 4
  Modified: Tue Nov 16 15:23:15 2010
  Imported: Mon Nov 22 09:26:32 2010
  Children: '/usr/share/nav/htdocs/seeddb/initBox.py',
                '/usr/share/nav/htdocs/seeddb/options.py',
                '/usr/share/nav/htdocs/seeddb/seeddbSQL.py'
}

_mp_6075681fed6c7055dc97214a475ff87e {
  FileName: '/usr/share/nav/htdocs/seeddb/seeddbSQL.py'
  Instance: 1
  Generation: 3
  Modified: Tue Nov 16 15:23:15 2010
  Imported: Mon Nov 22 09:26:32 2010
}

Revision history for this message
Morten Brekkevold (mbrekkevold) wrote :

So far, I'm unable to reproduce this. Adding a server, changing it's IP and then deleting it works just fine for me, but I will go on to check the code points from the traceback.

Changed in nav:
assignee: nobody → Morten Brekkevold (mbrekkevold)
Revision history for this message
Morten Brekkevold (mbrekkevold) wrote :

Steinar, the first error occurs inside some error handling code, which suggests that the database signalled an error during the delete operation. Since this error message has been masked by the error in the error handling code (!), could you please check the PostgreSQL logs to see what the error message there is when attempting to delete the device?

The second error message tells me that there is already an IP device registered with this IP in the database. Are you sure the old device actually had its IP address changed?

Changed in nav:
status: New → Incomplete
Revision history for this message
Morten Brekkevold (mbrekkevold) wrote :

I've fixed the crash problem inside the error handling routine, and added more details to the displayed error message here: http://metanav.uninett.no/hg/series/3.7.x/rev/7bdc2cb9cdd6

It still remains to be seen what the *real*, underlying error is.

Revision history for this message
Morten Brekkevold (mbrekkevold) wrote :

Well, Steinar, I forgot that I can actually check your logs myself, since we actually operate your installation from here :-)

Seems that there is a problematic foreign key reference in the alert system that prevents you from deleting an IP device if a user has an alert about this IP device in his/her personal alert queue. The actual error message from the logs is:

 ERROR: update or delete on table "alertq" violates foreign key constraint "accountalertqueue
_alert_id_fkey" on table "accountalertqueue"

The SeedDB error handling crash and this are to separate issues; I'm going to file the integrity issue as a separate bug report.

Changed in nav:
importance: Undecided → Medium
milestone: none → 3.7.1
status: Incomplete → Fix Committed
summary: - SeedDB crash when deleting ip device
+ SeedDB crashes on unknown IntegrityErrors during delete
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.