commanded / eventstore

Event store using PostgreSQL for persistence
MIT License
1.05k stars 146 forks source link

Prevent forwarding DOWN message to observing process, when monitor pr… #262

Closed kklisura closed 1 year ago

kklisura commented 2 years ago

…ocess exists.

I've observed lot of following errors logs when running tests on one of my projects, despite successful tests.

10:33:29.698 [error] gen_server <0.10703.0> terminated with reason: no function clause matching 'Elixir.DBConnection.ConnectionPool':handle_info({'DOWN',#Ref<0.1145699320.2707685377.197588>,process,<0.10706.0>,shutdown}, {ready,#Ref<0.1145699320.2707816451.176105>,#{delay => 0,idle => #Ref<0.1145699320.2707685377.197585>,...},...}) line 73

Eventually I think I was able to trace the root cause to this dependency.

When monitoring the underlying process here and here the MonitoredServer will monitor for the caller process as well. Once the caller process exists, a DOWN message will not be handled by the MonitoredServer, but it will be passed to underlying process. I believe the intention here was when the caller process exists, its monitor is removed from state.

I believe the error we were receiving were originating from the supervisor during the shutdown. When the AdvisoryLocks process exists, a DOWN message is sent to MonitoredServer due to AdvisoryLock monitor. When this message gets received it's being passed down to underlying process, which is DBConnection.ConnectionPool in our case.

Possible resolves https://github.com/elixir-ecto/db_connection/issues/214.

slashdotdash commented 1 year ago

Included in #272.

kklisura commented 1 year ago

Included in #272.

Thanks @slashdotdash. I appreciate you resolving this!