Skip to content

Commit

Permalink
fix: Do not await full setup to configure dropping replication slot (#…
Browse files Browse the repository at this point in the history
…2137)

Encountered an error in cloud work where the call to configure dropping
the replication slot would time out because the connection manager would
not become `active` - since this call only sets a configuration
parameter, I think that the connection manager should handle the slot
drop internally.

I've unblocked the configuration call, and made it so that it just logs
a warning if a connection pool is not available to drop the slot.
  • Loading branch information
msfstef authored Dec 10, 2024
1 parent a2903ed commit 309ac75
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/healthy-comics-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@core/sync-service": patch
---

Do not await full setup for configuring replication slot drop.
7 changes: 5 additions & 2 deletions packages/sync-service/lib/electric/connection/manager.ex
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ defmodule Electric.Connection.Manager do
end

def drop_replication_slot_on_stop(server) do
await_active(server)
GenServer.call(server, :drop_replication_slot_on_stop)
end

Expand Down Expand Up @@ -410,7 +409,7 @@ defmodule Electric.Connection.Manager do
drop_slot(state)
end

{:noreply, %{state | shape_log_collector_pid: nil}}
{:noreply, %{state | shape_log_collector_pid: nil, replication_client_pid: nil}}
end

# Periodically log the status of the lock connection until it is acquired for
Expand Down Expand Up @@ -668,6 +667,10 @@ defmodule Electric.Connection.Manager do
log_collector_pid
end

defp drop_slot(%{pool_pid: nil} = _state) do
Logger.warning("Skipping slot drop, pool connection not available")
end

defp drop_slot(%{pool_pid: pool} = state) do
publication_name = Keyword.fetch!(state.replication_opts, :publication_name)
slot_name = Keyword.fetch!(state.replication_opts, :slot_name)
Expand Down

0 comments on commit 309ac75

Please sign in to comment.