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

chore(electric): Improve error messages when the replication slot is already in use #1226

Merged
merged 2 commits into from
Jun 4, 2024
Merged
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
33 changes: 29 additions & 4 deletions components/electric/lib/electric/replication/postgres_connector.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ defmodule Electric.Replication.PostgresConnector do
require Logger

alias Electric.Replication.Connectors
alias Electric.Replication.Postgres.LogicalReplicationProducer
alias Electric.Replication.PostgresConnectorMng
alias Electric.Replication.PostgresConnectorSup

Expand Down Expand Up @@ -87,7 +88,7 @@ defmodule Electric.Replication.PostgresConnector do
end

defp log_child_error(
:postgres_producer,
LogicalReplicationProducer,
{:bad_return_value,
{:error,
{:error, :error, "55006", :object_in_use, "replication slot" <> _ = msg, _c_stacktrace}}},
Expand All @@ -99,12 +100,36 @@ defmodule Electric.Replication.PostgresConnector do
Failed to establish replication connection to Postgres:
#{msg}
""",
"Another instance of Electric appears to be connected to this database."
"""
Another instance of Electric appears to be connected to this database.
Refer to https://github.com/electric-sql/electric/issues/971 for additional info.
"""
)
end

defp log_child_error(
LogicalReplicationProducer,
{:bad_return_value,
{:error,
{:error, :error, "42710", :duplicate_object, "replication slot " <> _ = msg,
_c_stacktrace}}},
_connector_config
) do
Electric.Errors.print_error(
:conn,
"""
Failed to establish replication connection to Postgres:
#{msg}
""",
"""
Another instance of Electric appears to be connected to this database.
Refer to https://github.com/electric-sql/electric/issues/971 for additional info.
"""
)
end

defp log_child_error(
:postgres_producer,
LogicalReplicationProducer,
{:bad_return_value, {:error, :wal_level_not_logical}},
_connector_config
) do
Expand All @@ -119,7 +144,7 @@ defmodule Electric.Replication.PostgresConnector do
end

defp log_child_error(
:postgres_producer,
LogicalReplicationProducer,
{:bad_return_value, {:error, {:create_replication_slot_syntax_error, msg}}},
_connector_config
) do
Expand Down
Loading