cpursley / walex

Postgres change events (CDC) in Elixir
MIT License
276 stars 14 forks source link

remove overriding child_spec #43

Closed DohanKim closed 7 months ago

DohanKim commented 7 months ago

We are overriding WalEx supervisor's child_spec without setting type key which makes the type as default :worker instead of :supervisor ( https://hexdocs.pm/elixir/1.12/Supervisor.html#module-child-specification )

can check it by running

MyApp.Supervisor.which_children()

shows

[
  ...
  {WalEx.Supervisor, #PID<0.617.0>, :worker, [WalEx.Supervisor]},
  ...
]

This makes the whole app crash whenever any of the Event modules or other WalEx processes crashes.

we have choices of

I chose the latter as there is no significant reason to override the child_spec.

cpursley commented 7 months ago

Great find, thank you! I will review this weekend.

DohanKim commented 7 months ago

Sorry, the original code doesn't necessarily crash the whole app as we are using supervisor hierarchy. But still, this can cause unexpected behavior when a direct child is terminated.

cpursley commented 7 months ago

Are you running on more than one node?

DohanKim commented 7 months ago

@cpursley no, running only 1 node