[CONTROLLER-995] Clustering : StatisticsManager throws NPE when running single node integration tests Created: 05/Nov/14  Updated: 25/Jul/23  Resolved: 14/Nov/14

Status: Resolved
Project: controller
Component/s: mdsal
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Moiz Raja Assignee: Moiz Raja
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


External issue ID: 2317

 Description   

2014-10-31 11:29:44,687 | ERROR | -notification-21 | NotifyTask | 140 - org.opendaylight.controller.sal-binding-broker-impl - 1.2.0.SNAPSHOT | Unhandled exception thrown by listener: org.opendaylight.controller.md.statistics.manager.impl.StatListenCommitFlow$$Broker$ListenerInvoker@5d22f281
java.lang.NullPointerException
at org.opendaylight.controller.md.statistics.manager.impl.StatAbstractNotifyCommit.isExpectedStatistics(StatAbstractNotifyCommit.java:125)[151:org.opendaylight.controller.md.statistics-manager:1.2.0.SNAPSHOT]
at
This exception happens many many times during the test and may be the root cause for why some data appears to be missing in the datastore.

org.opendaylight.controller.md.statistics.manager.impl.StatListenCommitFlow.onFlowsStatisticsUpdate(StatListenCommitFlow.java:172)[151:org.opendaylight.controller.md.statistics-manager:1.2.0.SNAPSHOT]
at org.opendaylight.controller.md.statistics.manager.impl.StatListenCommitFlow$$Broker$ListenerInvoker.onNotification(StatListenCommitFlow$$Broker$ListenerInvoker.java)[151:org.opendaylight.controller.md.statistics-manager:1.2.0.SNAPSHOT]
at org.opendaylight.controller.sal.binding.impl.AbstractNotificationListenerRegistration.notify(AbstractNotificationListenerRegistration.java:38)[140:org.opendaylight.controller.sal-binding-broker-impl:1.2.0.SNAPSHOT]
at org.opendaylight.controller.sal.binding.impl.NotifyTask.run(NotifyTask.java:42)[140:org.opendaylight.controller.sal-binding-broker-impl:1.2.0.SNAPSHOT]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_65]
at java.util.concurrent.FutureTask.run(FutureTask.java:262)[:1.7.0_65]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_65]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_65]
at java.lang.Thread.run(Thread.java:745)[:1.7.0_65]



 Comments   
Comment by Moiz Raja [ 05/Nov/14 ]

protected boolean isExpectedStatistics(final TransactionId transId, final NodeId nodeId) {
Boolean isExpectedStat = Boolean.FALSE;
try

{ isExpectedStat = manager.getRpcMsgManager().isExpectedStatistics(transId, nodeId).get(10, TimeUnit.SECONDS); // Exception caused by this line }

catch (InterruptedException | ExecutionException | TimeoutException e) {
LOG.warn("Check Transaction registraion {} fail!", transId, e);
return false;
}
return isExpectedStat.booleanValue();
}

  1. manager - is an invariant and cannot be null
  2. manager.getRpcMsgManager() - could be null, it is set to null in StatisticsManagerImpl#close
  3. manager.getRpcMsgManager().isExpectedStatistics(transId, nodeId) - cannot be null because isExpectedStatistics does not return a null

It seems to be that StatisticsManagerImpl close is called at some point and that results in things getting messed up thenceforth.

Comment by Moiz Raja [ 05/Nov/14 ]

My initial analysis suggests that this may be an issue with StatisticsManager not unregistering for notifications properly. This can happen when the configuration is changed (config sub-system). For example when we switch from in-memory to clustered datastore the databroker gets rewired which results in all apps that use the databroker getting rewired. At that time the statistics manager's close will be called. The statistics manager should unregister from all notifications at this point. If it does not then it may receive notifications and since close sets the variables to null results in an NPE.

Comment by Moiz Raja [ 05/Nov/14 ]

StatsManagerImpl#close does call close on all the "*Comiter" and "*Registration" class instances. That should have unregistered the notifications ???

Comment by Moiz Raja [ 06/Nov/14 ]

https://git.opendaylight.org/gerrit/#/c/12585 - HELIUM

Comment by Moiz Raja [ 14/Nov/14 ]

Merged to both master and stable/helium

Generated at Wed Feb 07 19:54:25 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.