Skip to content

Commit

Permalink
Use exponential backoff when restoring a crashed replication connecti…
Browse files Browse the repository at this point in the history
…on (#2166)

Fixes #1960.

I have manually verified that attempts to restore the replication
connection now respect exponential backoff and that it eventually
connects if I stop the other Electric instance that was holding the
replication slot.
  • Loading branch information
alco authored Dec 24, 2024
1 parent bfdbd49 commit b64c900
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/sync-service/lib/electric/connection/manager.ex
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,9 @@ defmodule Electric.Connection.Manager do
"Handling the exit of the replication client #{inspect(pid)} with reason #{inspect(reason)}"
)

{:noreply, %{state | replication_client_pid: nil}, {:continue, :start_replication_client}}
state = %{state | replication_client_pid: nil}
state = schedule_reconnection(:start_replication_client, state)
{:noreply, state}
end

# The most likely reason for the lock connection or the DB pool to exit is the database
Expand Down

0 comments on commit b64c900

Please sign in to comment.