linkd needs to "upsert" entries in the ipRouteInterface, atinterface, vlan tables

Description

I recently closed bug https://opennms.atlassian.net/browse/NMS-4005#icft=NMS-4005 but there was one remaining issue in that bug that we should look into. linkd appears to be trying to perform an INSERT instead of an UPDATE for an entry in the ipRouteInterface table. I think that Matt's "upsert" database pattern might be useful in this case. The following stack trace is copied out of https://opennms.atlassian.net/browse/NMS-4005#icft=NMS-4005:

org.springframework.dao.DataIntegrityViolationException: could not insert: [org.opennms.netmgt.model.OnmsIpRouteInterface]; SQL [insert into ipRouteInterface (lastPollTime, nodeId, routeDest, routeIfIndex, routeMask, routeMetric1, routeMetric2, routeMetric3, routeMetric4, routeMetric5, routeNextHop, routeProto, routeType, status, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; constraint [pk_iprouteinterface]; nested exception is org.hibernate.exception.ConstraintViolationException: could not insert: [org.opennms.netmgt.model.OnmsIpRouteInterface]
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:637)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:737)
at org.opennms.netmgt.dao.hibernate.AbstractDaoHibernate.saveOrUpdate(AbstractDaoHibernate.java:425)
at org.opennms.netmgt.linkd.HibernateEventWriter.saveIpRouteInterface(HibernateEventWriter.java:503)
at org.opennms.netmgt.linkd.AbstractQueryManager.processRouteTable(AbstractQueryManager.java:420)
at org.opennms.netmgt.linkd.HibernateEventWriter.storeSnmpCollection(HibernateEventWriter.java:199)
at org.opennms.netmgt.linkd.Linkd.updateNodeSnmpCollection(Linkd.java:570)
at org.opennms.netmgt.linkd.SnmpCollection.run(SnmpCollection.java:516)
at org.opennms.netmgt.linkd.scheduler.Scheduler$1.run(Scheduler.java:301)
at org.opennms.core.concurrent.RunnableConsumerThreadPool$FiberThreadImpl.run(RunnableConsumerThreadPool.java:420)
at java.lang.Thread.run(Thread.java:662)

Acceptance / Success Criteria

None

Attachments

1
  • 02 Nov 2011, 11:28 PM

depends on

is duplicated by

Lucidchart Diagrams

Activity

Antonio Russo March 3, 2015 at 3:56 AM

In any case Linkd is replaced by enhanced linkd

Benjamin Reed October 2, 2014 at 11:00 AM

Looking at the code, it does appear to be properly doing "upsert" updates for Linkd data, perhaps there's something different going on with your particular issue. Mind opening a bug with a bit more info? Perhaps you're actually getting duplicate data from a bad table or multiple nodes with the same thing defined and that's what's causing your error?

Richard Hesse October 1, 2014 at 2:24 PM

Was this closed because it was fixed in another issue? I don't think this was actually fixed.

Richard Hesse June 16, 2014 at 9:22 PM

I'm running into this in 1.12.6. I'm guessing that the fix wasn't merged right, or it didn't actually resolve the issue.

@40000000539f98471493fb84 Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "pk_atinterface"
@40000000539f984714942a64 Detail: Key (nodeid, ipaddr, atphysaddr)=(791, 10.x.x.x, xxxxxxxxxxxx) already exists.

Antonio Russo August 28, 2012 at 4:11 AM

This has been resolved in master 11.2-SNAPSHOT

Cannot Reproduce

Details

Assignee

Reporter

Labels

Affects versions

Priority

PagerDuty

Created October 27, 2011 at 4:38 PM
Updated April 3, 2015 at 3:38 PM
Resolved March 3, 2015 at 3:56 AM

Flag notifications