Content-Length: 389192 | pFad | http://github.com/electric-sql/electric/pull/2844/files

9C Debugging the shutdown sequence of Electric.Connection.Supervisor by alco · Pull Request #2844 · electric-sql/electric · GitHub
Skip to content

Debugging the shutdown sequence of Electric.Connection.Supervisor #2844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/sync-service/lib/electric/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defmodule Electric.Application do

Supervisor.start_link(
children_application(),
[auto_shutdown: :any_significant] ++ supervisor_opts
supervisor_opts
)
end
end
Expand Down
17 changes: 16 additions & 1 deletion packages/sync-service/lib/electric/connection/manager.ex
Original file line number Diff line number Diff line change
Expand Up @@ -593,10 +593,17 @@ defmodule Electric.Connection.Manager do
# Supervisors send `:shutdown` exit signals to its children when they themselves are shutting
# down. We don't need to react to this signal coming from any of our linked processes, just
# ignore it.
def handle_info({:EXIT, _, :shutdown}, state), do: {:noreply, state}
def handle_info({:EXIT, _, :shutdown}, state) do
Logger.debug("Connection manager #{inspect(self())} received shutdown signal, stopping")
{:noreply, state}
end

# A process exited as it was trying to open a database connection.
def handle_info({:EXIT, pid, reason}, %State{current_phase: :connection_setup} = state) do
Logger.debug(
"Connection manager #{inspect(self())} received EXIT signal from #{inspect(pid)} :: #{inspect(reason)} during connection_setup phase"
)

# Try repairing the connection opts and try connecting again. If we're already using noSSL
# and IPv4, the error will be propagated to a `shutdown_or_reconnect()` function call
# further down below.
Expand Down Expand Up @@ -637,6 +644,10 @@ defmodule Electric.Connection.Manager do
{:EXIT, pid, reason},
%State{replication_client_pid: pid, current_phase: :running} = state
) do
Logger.debug(
"Connection manager #{inspect(self())} received EXIT signal from replication client #{inspect(pid)} :: #{inspect(reason)}"
)

state = nillify_pid(state, pid)
error = strip_exit_signal_stacktrace(reason)

Expand All @@ -653,6 +664,10 @@ defmodule Electric.Connection.Manager do
# bunch of them is the database server going offline or shutting down. Stop
# Connection.Manager to allow its supervisor to restart it in the initial state.
def handle_info({:EXIT, pid, reason}, state) do
Logger.debug(
"Connection manager #{inspect(self())} received EXIT signal from #{inspect(pid)} :: #{inspect(reason)}"
)

error =
reason
|> strip_exit_signal_stacktrace()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ defmodule Electric.Connection.Supervisor do
# The `restart: :transient, significant: true` combo allows for shutting the supervisor down
# and signalling the parent supervisor to shut itself down as well if that one has
# `:auto_shutdown` set to `:any_significant` or `:all_significant`.
use Supervisor, restart: :transient, significant: true
use Supervisor, restart: :transient

require Logger

Expand Down
5 changes: 2 additions & 3 deletions packages/sync-service/lib/electric/stack_supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ defmodule Electric.StackSupervisor do
]
else
[
restart: :transient,
restart: :transient
# Make StackSupervisor `significant` so that in the case that electric is in single-stack mode, the stack stopping
# will stop the entire Electric application (since `auto_shutdown` is set to `:any_significant` in `Application`).
significant: true
]
end

Expand Down Expand Up @@ -372,6 +371,6 @@ defmodule Electric.StackSupervisor do
telemetry_span_attrs
)

Supervisor.init(children, strategy: :one_for_one, auto_shutdown: :any_significant)
Supervisor.init(children, strategy: :one_for_one)
end
end
Loading








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/electric-sql/electric/pull/2844/files

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy