Uploaded image for project: 'OpenNMS'
  1. OpenNMS
  2. NMS-4717

race condition in Provisiond IPv6 scanning

    Details

      Description

      In some cases, when scanning hosts supporting the newer ipAddress table, a race condition would cause a concurrency exception while trying to write SNMP interface data:

      2011-05-25 09:24:55,448 ERROR [writeExecutor-1] org.hibernate.util.JDBCExceptionReporter: ERROR: duplicate key value violates unique constraint "snmpinterface_nodeid_ifindex_unique_idx"
      Detail: Key (nodeid, snmpifindex)=(1, 2) already exists.
      2011-05-25 09:24:55,451 DEBUG [scanExecutor-17] org.opennms.netmgt.provision.service.DefaultPluginRegistry: Found bean org.opennms.netmgt.provision.detector.icmp.IcmpDetector@28ee8874 with name org.opennms.netmgt.provision.detector.icmp.IcmpDetector of type interface org.opennms.netmgt.provision.ServiceDetector
      2011-05-25 09:24:55,448 DEBUG [writeExecutor-4] org.opennms.netmgt.mock.MockEventIpcManager: StartEvent processing (1 remaining)
      2011-05-25 09:24:55,453 DEBUG [writeExecutor-4] org.opennms.netmgt.mock.MockEventIpcManager: Received:
      2011-05-25 09:24:55,455 ERROR [writeExecutor-1] org.hibernate.event.def.AbstractFlushingEventListener: Could not synchronize database state with session
      org.hibernate.exception.ConstraintViolationException: could not insert: [org.opennms.netmgt.model.OnmsSnmpInterface]
      at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:94)
      at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
      at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2295)
      at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2688)
      at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)
      at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
      at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
      at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
      at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
      at org.springframework.orm.hibernate3.HibernateTemplate$28.doInHibernate(HibernateTemplate.java:883)
      at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
      at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
      at org.springframework.orm.hibernate3.HibernateTemplate.flush(HibernateTemplate.java:881)
      at org.opennms.netmgt.dao.hibernate.AbstractDaoHibernate.flush(AbstractDaoHibernate.java:82)
      at org.opennms.netmgt.provision.service.DefaultProvisionService.updateSnmpInterfaceAttributes(DefaultProvisionService.java:298)
      at org.opennms.netmgt.provision.service.DefaultProvisionService.updateIpInterfaceAttributes(DefaultProvisionService.java:244)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
      at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
      at $Proxy62.updateIpInterfaceAttributes(Unknown Source)
      at org.opennms.netmgt.provision.service.NodeScan$BaseAgentScan.updateIpInterface(NodeScan.java:746)
      at org.opennms.netmgt.provision.service.NodeScan$BaseAgentScan$1.run(NodeScan.java:755)
      at org.opennms.core.tasks.SyncTask.run(SyncTask.java:92)
      at org.opennms.core.tasks.SyncTask$1.run(SyncTask.java:103)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
      at java.util.concurrent.FutureTask.run(FutureTask.java:138)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
      at java.util.concurrent.FutureTask.run(FutureTask.java:138)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
      at java.util.concurrent.FutureTask.run(FutureTask.java:138)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:680)
      Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "snmpinterface_nodeid_ifindex_unique_idx"
      Detail: Key (nodeid, snmpifindex)=(1, 2) already exists.
      at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102)
      at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835)
      at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
      at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500)
      at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:334)
      at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:46)
      at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2275)
      ... 44 more

        Attachments

          Activity

            People

            • Assignee:
              ranger Benjamin Reed
              Reporter:
              ranger Benjamin Reed
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: