From 3d26a5105c35a2b70fe94cca9f7085c2c30e415e Mon Sep 17 00:00:00 2001 From: msfstef Date: Tue, 26 Nov 2024 18:15:18 +0200 Subject: [PATCH] Log error without falling over for failed recovery --- .changeset/warm-brooms-approve.md | 5 +++++ packages/sync-service/lib/electric/shape_cache.ex | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changeset/warm-brooms-approve.md diff --git a/.changeset/warm-brooms-approve.md b/.changeset/warm-brooms-approve.md new file mode 100644 index 0000000000..d4d4c14ff1 --- /dev/null +++ b/.changeset/warm-brooms-approve.md @@ -0,0 +1,5 @@ +--- +"@core/sync-service": patch +--- + +Log error but don't fall over if failing to initialise recovered shape diff --git a/packages/sync-service/lib/electric/shape_cache.ex b/packages/sync-service/lib/electric/shape_cache.ex index 2dbf0602e1..fdfe7895b7 100644 --- a/packages/sync-service/lib/electric/shape_cache.ex +++ b/packages/sync-service/lib/electric/shape_cache.ex @@ -318,7 +318,11 @@ defmodule Electric.ShapeCache do state.shape_status_state |> state.shape_status.list_shapes() |> Enum.each(fn {shape_handle, shape} -> - {:ok, _pid, _snapshot_xmin, _latest_offset} = start_shape(shape_handle, shape, state) + try do + {:ok, _pid, _snapshot_xmin, _latest_offset} = start_shape(shape_handle, shape, state) + rescue + e -> Logger.error("Failed to recover shape #{shape_handle}: #{inspect(e)}") + end end) end