OpenNMS 24 Node deletion

troubleshooting
#1

Issue deleting existing node. Been using OpenNMS for years now and I am a HUGE fan. Recently tried to upgrade to version 24 and did not go as planned. However, this is a home setup and I did make a backup so easy matter of just rebuilding my Ubuntu 18.04 server and re-install OpenNMS 24. All went very well and the restore was easy and thought I was golden. However, I noticed that I can’t delete a node anymore as it just wouldn’t go away. No biggy as this is my home “lab” so I just blew it away again and let discovery populate my nodes. Again, everything looked great with all nodes discovered. However, I again went to delete a node and can’t. Wasn’t sure if anyone else seen this or not but I am getting the following error in provisiond.log. Any ideas are greatly appreciated.

2019-04-30 18:41:29,130 WARN  [Provisiond:EventListener-Thread] o.h.u.JDBCExceptionReporter: SQL Error: 0, SQLState: 23503
2019-04-30 18:41:29,131 ERROR [Provisiond:EventListener-Thread] o.h.u.JDBCExceptionReporter: ERROR: update or delete on table "node" violates foreign key constraint "fk_ipnettomedia_nodeid" on table "ipnettomedia"
  Detail: Key (nodeid)=(11) is still referenced from table "ipnettomedia".
2019-04-30 18:41:29,131 ERROR [Provisiond:EventListener-Thread] o.o.n.p.s.Provisioner: Unexpected exception processing event: uei.opennms.org/internal/capsd/deleteNode
org.springframework.dao.DataIntegrityViolationException: could not delete: [org.opennms.netmgt.model.OnmsNode#11]; SQL [delete from node where nodeId=?]; constraint [fk_ipnettomedia_nodeid]; nested exception is org.hibernate.exception.ConstraintViolationException: could not delete: [org.opennms.netmgt.model.OnmsNode#11]
        at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:659) ~[org.apache.servicemix.bundles.spring-orm-4.2.9.RELEASE_1.jar:?]
        at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:414) ~[org.apache.servicemix.bundles.spring-orm-4.2.9.RELEASE_1.jar:?]
        at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:415) ~[org.apache.servicemix.bundles.spring-orm-4.2.9.RELEASE_1.jar:?]
        at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:378) ~[org.apache.servicemix.bundles.spring-orm-4.2.9.RELEASE_1.jar:?]
        at org.springframework.orm.hibernate3.HibernateTemplate.flush(HibernateTemplate.java:937) ~[org.apache.servicemix.bundles.spring-orm-4.2.9.RELEASE_1.jar:?]
        at org.opennms.netmgt.dao.hibernate.AbstractDaoHibernate.flush(AbstractDaoHibernate.java:94) ~[opennms-dao-24.0.0.jar:?]
        at org.opennms.netmgt.provision.service.DefaultProvisionService.deleteNode(DefaultProvisionService.java:310) ~[opennms-provisiond-24.0.0.jar:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_131]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131]
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302) ~[org.apache.servicemix.bundles.spring-aop-4.2.9.RELEASE_1.jar:?]
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) ~[org.apache.servicemix.bundles.spring-aop-4.2.9.RELEASE_1.jar:?]
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[org.apache.servicemix.bundles.spring-aop-4.2.9.RELEASE_1.jar:?]
        at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) ~[org.apache.servicemix.bundles.spring-tx-4.2.9.RELEASE_1.jar:?]
        at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) ~[org.apache.servicemix.bundles.spring-tx-4.2.9.RELEASE_1.jar:?]
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) ~[org.apache.servicemix.bundles.spring-tx-4.2.9.RELEASE_1.jar:?]
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[org.apache.servicemix.bundles.spring-aop-4.2.9.RELEASE_1.jar:?]
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208) ~[org.apache.servicemix.bundles.spring-aop-4.2.9.RELEASE_1.jar:?]
        at com.sun.proxy.$Proxy177.deleteNode(Unknown Source) ~[?:?]
        at org.opennms.netmgt.provision.service.Provisioner.doDeleteNode(Provisioner.java:826) ~[opennms-provisiond-24.0.0.jar:?]
        at org.opennms.netmgt.provision.service.Provisioner.handleDeleteNode(Provisioner.java:819) [opennms-provisiond-24.0.0.jar:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_131]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131]
        at org.opennms.netmgt.events.api.AnnotationBasedEventListenerAdapter.processEvent(AnnotationBasedEventListenerAdapter.java:221) [org.opennms.features.events.api-24.0.0.jar:?]
        at org.opennms.netmgt.events.api.AnnotationBasedEventListenerAdapter$1.run(AnnotationBasedEventListenerAdapter.java:182) [org.opennms.features.events.api-24.0.0.jar:?]
        at org.opennms.core.logging.Logging.withPrefix(Logging.java:71) [org.opennms.core.logging-24.0.0.jar:?]
        at org.opennms.netmgt.events.api.AnnotationBasedEventListenerAdapter.onEvent(AnnotationBasedEventListenerAdapter.java:175) [org.opennms.features.events.api-24.0.0.jar:?]
        at org.opennms.netmgt.eventd.EventIpcManagerDefaultImpl$EventListenerExecutor$2.run(EventIpcManagerDefaultImpl.java:189) [org.opennms.features.events.daemon-24.0.0.jar:?]
        at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1626) [?:1.8.0_131]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_131]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_131]
        at org.opennms.core.concurrent.LogPreservingThreadFactory$2.run(LogPreservingThreadFactory.java:106) [opennms-util-24.0.0.jar:?]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_131]
Caused by: org.hibernate.exception.ConstraintViolationException: could not delete: [org.opennms.netmgt.model.OnmsNode#11]
        at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:96) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
        at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2729) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
        at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2912) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
        at org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:97) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
        at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:265) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:189) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
        at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
        at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
        at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
        at org.springframework.orm.hibernate3.HibernateTemplate$27.doInHibernate(HibernateTemplate.java:940) ~[org.apache.servicemix.bundles.spring-orm-4.2.9.RELEASE_1.jar:?]
        at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:410) ~[org.apache.servicemix.bundles.spring-orm-4.2.9.RELEASE_1.jar:?]
        ... 33 more
Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table "node" violates foreign key constraint "fk_ipnettomedia_nodeid" on table "ipnettomedia"
  Detail: Key (nodeid)=(11) is still referenced from table "ipnettomedia".
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440) ~[postgresql-42.2.5.jar:42.2.5]
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183) ~[postgresql-42.2.5.jar:42.2.5]
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308) ~[postgresql-42.2.5.jar:42.2.5]
        at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441) ~[postgresql-42.2.5.jar:42.2.5]
        at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365) ~[postgresql-42.2.5.jar:42.2.5]
        at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:143) ~[postgresql-42.2.5.jar:42.2.5]
        at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:120) ~[postgresql-42.2.5.jar:42.2.5]
        at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105) ~[c3p0-0.9.1.1.jar:0.9.1.1]
        at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:46) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
        at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2708) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
        at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2912) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
        at org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:97) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
        at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:265) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:189) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
        at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
        at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
        at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216) ~[hibernate-core-3.6.10.Final.jar:3.6.10.Final]
        at org.springframework.orm.hibernate3.HibernateTemplate$27.doInHibernate(HibernateTemplate.java:940) ~[org.apache.servicemix.bundles.spring-orm-4.2.9.RELEASE_1.jar:?]
        at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:410) ~[org.apache.servicemix.bundles.spring-orm-4.2.9.RELEASE_1.jar:?]
        ... 33 more