Closed Aaronontheweb closed 8 years ago
Broadening this issue to cover race conditions within TestTransport
in general - just found this gem inside Akka.Remote.Tests.Performance
:
Fails with the following exception as reported by NBench:
NBench.NBenchException: Error occurred during $Akka.Remote.Tests.Performance.TestTransportRemoteMessagingThroughputSpec+OneWay SETUP. ---> System.AggregateException: One or more errors occurred. ---> System.Threading.Tasks.TaskCanceledException: A task was canceled.
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at Akka.Remote.Tests.Performance.RemoteMessagingThroughputSpecBase.Setup(BenchmarkContext context) in D:\BuildAgent\work\49b164d63843fb4\src\core\Akka.Remote.Tests.Performance\RemoteMessagingThroughputSpecBase.cs:line 87
at NBench.Sdk.ReflectionBenchmarkInvoker.InvokePerfSetup(BenchmarkContext context)
at NBench.Sdk.Benchmark.PreRun()
--- End of inner exception stack trace ---
NBench.NBenchException: Error occurred during $Akka.Remote.Tests.Performance.TestTransportRemoteMessagingThroughputSpec+OneWay RUN. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at Akka.Remote.Tests.Performance.RemoteMessagingThroughputSpecBase.OneWay(BenchmarkContext context) in D:\BuildAgent\work\49b164d63843fb4\src\core\Akka.Remote.Tests.Performance\RemoteMessagingThroughputSpecBase.cs:line 106
at NBench.Sdk.Benchmark.RunBenchmark()
at NBench.Sdk.Benchmark.RunSingleBenchmark()
--- End of inner exception stack trace ---
No way an in-memory association should take longer than 2s to complete without some sort of underlying bug in the code.
I have a reliable test that can reproduce this now - going to step into it
Looks like the issue may be user error - from the original source:
/*
NOTE: This is a global shared state between different actor systems. The purpose of this class is to allow dynamically
loaded TestTransports to set up a shared AssociationRegistry. Extensions could not be used for this purpose, as the injection
of the shared instance must happen during the startup time of the actor system. Association registries are looked
up via a string key. Until we find a better way to inject an AssociationRegistry to multiple actor systems it is
strongly recommended to use long, randomly generated strings to key the registry to avoid interference between tests.
*/
object AssociationRegistry {
private final val registries = scala.collection.mutable.Map[String, AssociationRegistry]()
def get(key: String): AssociationRegistry = this.synchronized {
registries.getOrElseUpdate(key, new AssociationRegistry)
}
def clear(): Unit = this.synchronized { registries.clear() }
}
Modifying our benchmarks and tests to generate a new key for each test instance...
Yeah, looks like it - we were basically re-using the same AssociationRegistry
for TestTransport
between specs, which is static. Just need to use a random Guid
for the akka.remote.test-transport.registry-key
on each test run and we're good to go. Going to do some more work to verify but this looks resolved for now.
Looks like an issue that maybe occurs on shutdown or disassociation. Need to determine if it's an issue with the
TestTransport
or with something more "important" inside the remoting stack.