eligosource / eventsourced

A library for building reliable, scalable and distributed event-sourced applications in Scala
Apache License 2.0
828 stars 98 forks source link

RectiveMongo dirver's actor system is being shut down with the journal #121

Closed iskra-vitaly closed 11 years ago

iskra-vitaly commented 11 years ago

If the driver's actor system is not shut down it sometimes prevents application process from gracefull termination (even when sys.exit(0) is called) and causes thread leaks

krasserm commented 11 years ago

@iskra-vitaly @ddevore +1 for creating the MongoDriver with Some(context.system) as argument.

But, since an ActorSystem is always created and provided by an application (via EventsourcingExtension(system, ...)) it is the application's responsibility to shutdown the provided ActorSystem.

ironfish commented 11 years ago

@iskra-vitaly @krasserm

Thanks Martin for pointing this out, so I'll leave the close close method as is. I'll make note of this in the Reactive journal readme that the application should shutdown its actor system when shutting down reactive.

krasserm commented 11 years ago

@ddevore sounds good to me @iskra-vitaly do you see any issues to proceed as discussed and then closing the pull request? In any case, thanks you very much for your contribution.

iskra-vitaly commented 11 years ago

I think it makes sense if the journal implementation would pass the actor system it's being run in to the MongoDriver. One more thing to mention - this day I discovered that several threads like reactive-dispatcher-* remain running in the JVM even after driver's actor system is properly shut down. This looks very strange - more like reactivemongo's or akka's bug. I'll try to investigate this issue deeper after weekend.

ironfish commented 11 years ago

According to the source, askClose should shutdown the Reactive related actors on the host system, but I did find a thread where Stephane also recommends calling MongoDriver.close. I will add this to the journal close as well.

krasserm commented 11 years ago

@ddevore only closing the MongoDriver in the journal stop should be sufficient (as it internally closes all created connections). It also covers what @iskra-vitaly tried to solve in his pull request.

krasserm commented 11 years ago

@iskra-vitaly this issue should now be resolved with #124.