openbase / bco.dal

Domotic Abstraction Layer
Other
1 stars 2 forks source link

UnitPool is returning disabled units within scene tests. #78

Closed DivineThreepwood closed 6 years ago

DivineThreepwood commented 6 years ago

The issue is still not solved in which the scene manager test are failing during waitForData because the unit pool is returning a deactivated remote.

 [0;39mConnectionState update of root location remote[CONNECTING] isActive[false]
 38 23:16:40.732 [main] [1;31mERROR[0;39m [36mo.o.b.m.s.t.r.s.SceneRemoteTest[0;39m [1;31mCould not register scene!
 37 [0;39morg.openbase.jul.exception.CouldNotPerformException: Could not register scene!
 36     at org.openbase.bco.manager.scene.test.remote.scene.SceneRemoteTest.registerScenes(SceneRemoteTest.java:282)
 35     at org.openbase.bco.manager.scene.test.remote.scene.SceneRemoteTest.setUpClass(SceneRemoteTest.java:132)
 34     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 33     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 32     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 31     at java.lang.reflect.Method.invoke(Method.java:498)
 30     at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
 29     at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
 28     at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
 27     at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
 26     at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
 25     at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
 24     at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:367)
 23     at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:274)
 22     at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
 21     at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:161)
 20     at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:290)
 19     at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:242)
 18     at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121)
 17 Caused by: org.openbase.jul.exception.CouldNotPerformException: Could not wait for data!
 16     at org.openbase.jul.extension.rsb.com.RSBRemoteService.waitForData(RSBRemoteService.java:1162)
 15     at org.openbase.bco.dal.remote.unit.AbstractUnitRemote.waitForData(AbstractUnitRemote.java:424)
 14     at org.openbase.bco.manager.scene.test.remote.scene.SceneRemoteTest.registerScenes(SceneRemoteTest.java:227)
 13     ... 18 common frames omitted
 12 Caused by: java.util.concurrent.CancellationException: null
 11     at java.util.concurrent.CompletableFuture.cancel(CompletableFuture.java:2263)
 10     at org.openbase.jul.extension.rsb.com.RSBRemoteService$SyncTaskCallable.call(RSBRemoteService.java:1021)
  9     at org.openbase.jul.extension.rsb.com.RSBRemoteService$SyncTaskCallable.call(RSBRemoteService.java:983)
  8     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  7     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
  6     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
  5     at java.lang.Thread.run(Thread.java:748)

Using the lock for the reset and shutdown did not solve the issue.

Scene tests are know disabled again but we should highly investigate time to solve this issue and enable the tests afterwards.

pLeminoq commented 6 years ago

I think the issue is that the activation of a unit remote is not synchronized by Units. Therefore if one thread creates a new remote without getting to activate it before another thread takes over and then the second thread can return the remote inactive. As a solution I would propose that Units also activates units if they are inactive. But for this to work activate has to be implemented robustly anywhere which it currently probably is not. Robustly means that it is synchronized and can be called multiple times without causing errors. E.g. the RSBRemoteService currently would reset the connectionState to connecting.

DivineThreepwood commented 6 years ago

The unit action is not synchronized within the unit pool. This does not cause into any performance issues because the activation does not wait for any states anymore. Hopefully this issue is fixed now. Thanks for the nice error analysis @pLeminoq

DivineThreepwood commented 6 years ago

did not occur again :)