From a6819d518afe930b4cf32b2081ec40f404acb14a Mon Sep 17 00:00:00 2001 From: Erik the Implementer Date: Tue, 21 Apr 2026 13:02:25 +0200 Subject: [PATCH] Guard report_shape_db_stats against :noproc during deployments The telemetry poller calls ShapeDb.statistics/1, which resolves the GenServer pid and then issues a GenServer.call. During stack restarts the Statistics server can exit between those two steps, producing an uncaught :noproc exit from the poller. Mirror the existing try/catch pattern in report_retained_wal_size so these transient races no longer surface as Sentry errors. Refs electric-sql/stratovolt#1452 --- .../fix-report-shape-db-stats-noproc.md | 5 +++++ .../electric/stack_supervisor/telemetry.ex | 21 ++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 .changeset/fix-report-shape-db-stats-noproc.md diff --git a/.changeset/fix-report-shape-db-stats-noproc.md b/.changeset/fix-report-shape-db-stats-noproc.md new file mode 100644 index 0000000000..9b43a1d81e --- /dev/null +++ b/.changeset/fix-report-shape-db-stats-noproc.md @@ -0,0 +1,5 @@ +--- +'@core/sync-service': patch +--- + +Guard `report_shape_db_stats` telemetry poller against `:noproc` exits when the shape status GenServer terminates during stack restarts, mirroring the existing handling in `report_retained_wal_size`. diff --git a/packages/sync-service/lib/electric/stack_supervisor/telemetry.ex b/packages/sync-service/lib/electric/stack_supervisor/telemetry.ex index ed74295ed5..3983ae487c 100644 --- a/packages/sync-service/lib/electric/stack_supervisor/telemetry.ex +++ b/packages/sync-service/lib/electric/stack_supervisor/telemetry.ex @@ -138,15 +138,20 @@ defmodule Electric.StackSupervisor.Telemetry do end def report_shape_db_stats(stack_id, _telemetry_opts) do - case Electric.ShapeCache.ShapeStatus.ShapeDb.statistics(stack_id) do - {:ok, stats} -> - Electric.Telemetry.OpenTelemetry.execute( - [:electric, :shape_db, :sqlite], - stats, - %{stack_id: stack_id} - ) + try do + case Electric.ShapeCache.ShapeStatus.ShapeDb.statistics(stack_id) do + {:ok, stats} -> + Electric.Telemetry.OpenTelemetry.execute( + [:electric, :shape_db, :sqlite], + stats, + %{stack_id: stack_id} + ) - _ -> + _ -> + :ok + end + catch + :exit, {:noproc, _} -> :ok end end