Skip to content

Commit

Permalink
Leave notes to check error behaviour of epgsql conn resources
Browse files Browse the repository at this point in the history
  • Loading branch information
alco committed Sep 30, 2023
1 parent 0d4bc8a commit ee9adcb
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ defmodule Electric.Postgres.Extension.SchemaLoader.Epgsql do
# "ALTER SUBSCRIPTION ... REFRESH is not allowed for disabled subscriptions"
# ignore this as it's due to race conditions with the rest of the system
{:error, {:error, :error, "55000", :object_not_in_prerequisite_state, _, _}} ->
# TODO: Check if this leaves the connection in an unusable state
Logger.warning("Unable to refresh DISABLED subscription #{name}")
:ok

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ defmodule Electric.Replication.Postgres.Client do
end

def start_subscription(conn, name) do
# TODO: check if an error return here leaves conn in an unusable state
with {:ok, _, _} <- squery(conn, ~s|ALTER SUBSCRIPTION "#{name}" ENABLE|),
{:ok, _, _} <-
squery(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ defmodule Electric.Replication.PostgresConnectorMng do
)

ConnectionPool.checkout!(origin, fn conn ->
# TODO: check if an error return here leaves conn in an unusable state
with {:ok, versions} <- Extension.migrate(conn),
{:ok, _} <-
Client.create_subscription(conn, subscription, publication, electric_connection),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ defmodule Electric.Replication.Shapes.ShapeRequest do
{:ok, count, records}

{:error, _} = error ->
# TODO: check if this leaves conn in an usuable state
error
end
end
Expand Down

0 comments on commit ee9adcb

Please sign in to comment.