Skip to content
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

fix: Do not await full setup to configure dropping replication slot #2137

Merged
merged 3 commits into from
Dec 10, 2024
Merged
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
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're not calling await_active here, I imagine you're going to need to call await_active in this test in stratovolt to get it to pass.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really because the setup of the test ensures that the stack is :ready - that encapsulates awaiting for the connection manager to be ready

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
Loading