From ee9adcbf0672a00d765dc1bdf2e0d8bc2205c518 Mon Sep 17 00:00:00 2001 From: Oleksii Sholik Date: Sat, 30 Sep 2023 23:40:26 +0300 Subject: [PATCH] Leave notes to check error behaviour of epgsql conn resources --- .../lib/electric/postgres/extension/schema_loader/epgsql.ex | 1 + components/electric/lib/electric/replication/postgres/client.ex | 1 + components/electric/lib/electric/replication/postgres_manager.ex | 1 + .../electric/lib/electric/replication/shapes/shape_request.ex | 1 + 4 files changed, 4 insertions(+) diff --git a/components/electric/lib/electric/postgres/extension/schema_loader/epgsql.ex b/components/electric/lib/electric/postgres/extension/schema_loader/epgsql.ex index dce3c11b4e..85b64c2dda 100644 --- a/components/electric/lib/electric/postgres/extension/schema_loader/epgsql.ex +++ b/components/electric/lib/electric/postgres/extension/schema_loader/epgsql.ex @@ -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 diff --git a/components/electric/lib/electric/replication/postgres/client.ex b/components/electric/lib/electric/replication/postgres/client.ex index 9dd974ba39..d4dff63763 100644 --- a/components/electric/lib/electric/replication/postgres/client.ex +++ b/components/electric/lib/electric/replication/postgres/client.ex @@ -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( diff --git a/components/electric/lib/electric/replication/postgres_manager.ex b/components/electric/lib/electric/replication/postgres_manager.ex index 0c89298048..8f060ac75c 100644 --- a/components/electric/lib/electric/replication/postgres_manager.ex +++ b/components/electric/lib/electric/replication/postgres_manager.ex @@ -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), diff --git a/components/electric/lib/electric/replication/shapes/shape_request.ex b/components/electric/lib/electric/replication/shapes/shape_request.ex index d51fb0a53c..dee0cc917a 100644 --- a/components/electric/lib/electric/replication/shapes/shape_request.ex +++ b/components/electric/lib/electric/replication/shapes/shape_request.ex @@ -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