Skip to content

Catch pooled connection errors in Connection.Manager process #2804

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

Merged
merged 6 commits into from
Jun 16, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix tests
  • Loading branch information
alco committed Jun 11, 2025
commit 93fbf79f0ec1d94774cf8e0b18a0869b663e6284
14 changes: 14 additions & 0 deletions packages/sync-service/lib/electric/db_connection_error.ex
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,20 @@ defmodule Electric.DbConnectionError do
}
end

if Mix.env() == :test do
def from_error(:shutdown) do
%DbConnectionError{
message: "Test database connection has beed shutdown",
type: :shutdown,
original_error: :shutdown,
# We don't want for this error to be treated as fatal because what would interfere with the
# supervision startup/shutdown setup in tests. We just treat it as a retryable DB error
# and let the test code control supervision tree orchestration.
retry_may_fix?: true
}
end
end

def from_error(error), do: unknown_error(error)

def format_original_error(%DbConnectionError{original_error: error}) do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ defmodule Electric.Postgres.LockConnectionTest do

assert_lock_acquired()

# try to grab the same with another
new_stack_id = :"#{stack_id}_new"
# try to grab the same lock using a different connection
new_stack_id = stack_id <> "_new"
_registry = start_link_supervised!({Electric.ProcessRegistry, stack_id: new_stack_id})

assert {:ok, _pid} =
LockConnection.start_link(
Expand Down
2 changes: 1 addition & 1 deletion packages/sync-service/test/support/component_setup.ex
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ defmodule Support.ComponentSetup do
end

def with_registry(ctx) do
registry_name = :"#{Registry.ShapeChanges}:#{ctx.stack_id}"
registry_name = :"#{inspect(Registry.ShapeChanges)}:#{ctx.stack_id}"
start_link_supervised!({Registry, keys: :duplicate, name: registry_name})

%{registry: registry_name}
Expand Down
2 changes: 1 addition & 1 deletion packages/sync-service/test/support/test_utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ defmodule Support.TestUtils do
end

def full_test_name(ctx) do
"#{ctx.module} #{ctx.test}"
"#{inspect(ctx.module)} #{ctx.test}"
end

def ins(opts) do
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy