Skip to content

Potential sync service crash after restarting container and modifying row tracked by shape using subquery #3931

@markpsiano

Description

@markpsiano

Versions

  • Client: HTTP
  • Electric: 1.2.9

Bug description
When I stop the container running the sync service and restart it, modifying rows belonging to non-subquery using shapes has them properly picked up. But when I modify a row that should be picked up by a shape that uses a subquery, the service crashes with the error:

01:42:10.092 pid=<0.3457.0> [error] GenServer {:"Electric.ProcessRegistry:single_stack", {Electric.Replication.ShapeLogCollector, nil}} terminating
** (stop) exited in: GenServer.call({:via, Registry, {:"Electric.ProcessRegistry:single_stack", {Electric.Shapes.Consumer.Materializer, "43228226-1772242656181490"}}}, :get_link_values, 5000)
    ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
    (elixir 1.19.1) lib/gen_server.ex:1135: GenServer.call/3
    (electric 1.2.9) lib/electric/shapes/consumer/materializer.ex:65: anonymous fn/2 in Electric.Shapes.Consumer.Materializer.get_all_as_refs/2
    (elixir 1.19.1) lib/enum.ex:1688: Enum."-map/2-lists^map/1-1-"/2
    (elixir 1.19.1) lib/map.ex:267: Map.new_from_enum/2
    (electric 1.2.9) lib/electric/shapes/filter/where_condition.ex:210: anonymous fn/6 in Electric.Shapes.Filter.WhereCondition.other_shapes_affected/4
    (stdlib 7.1) maps.erl:894: :maps.fold_1/4
    (electric 1.2.9) lib/electric/shapes/filter/where_condition.ex:208: anonymous fn/4 in Electric.Shapes.Filter.WhereCondition.other_shapes_affected/4
    (electric 1.2.9) lib/electric/telemetry/open_telemetry.ex:89: anonymous fn/5 in Electric.Telemetry.OpenTelemetry.do_with_span/5
    (telemetry 1.3.0) /builder/electric/deps/telemetry/src/telemetry.erl:324: :telemetry.span/3
    (electric 1.2.9) lib/electric/shapes/filter/where_condition.ex:170: Electric.Shapes.Filter.WhereCondition.affected_shapes/3
    (electric 1.2.9) lib/electric/shapes/filter.ex:123: anonymous fn/2 in Electric.Shapes.Filter.affected_shapes/2
    (stdlib 7.1) timer.erl:599: :timer.tc/2
    (electric 1.2.9) lib/electric/telemetry/open_telemetry.ex:134: Electric.Telemetry.OpenTelemetry.timed_fun/3
    (electric 1.2.9) lib/electric/shapes/event_router.ex:149: Electric.Shapes.EventRouter.find_affected_shapes_for_change/2
    (electric 1.2.9) lib/electric/shapes/event_router.ex:106: Electric.Shapes.EventRouter.route_change/3
    (elixir 1.19.1) lib/enum.ex:2520: Enum."-reduce/3-lists^foldl/2-0-"/3
    (electric 1.2.9) lib/electric/shapes/event_router.ex:83: Electric.Shapes.EventRouter.event_by_shape_handle/2
    (electric 1.2.9) lib/electric/replication/shape_log_collector.ex:508: Electric.Replication.ShapeLogCollector.publish/2
    (electric 1.2.9) lib/electric/replication/shape_log_collector.ex:495: Electric.Replication.ShapeLogCollector.handle_txn_fragment/2
    (electric 1.2.9) lib/electric/replication/shape_log_collector.ex:431: anonymous fn/2 in Electric.Replication.ShapeLogCollector.do_handle_event/2
    (electric 1.2.9) lib/electric/telemetry/open_telemetry.ex:89: anonymous fn/5 in Electric.Telemetry.OpenTelemetry.do_with_span/5
    (telemetry 1.3.0) /builder/electric/deps/telemetry/src/telemetry.erl:324: :telemetry.span/3
    (electric 1.2.9) lib/electric/replication/shape_log_collector.ex:289: Electric.Replication.ShapeLogCollector.handle_call/3
    (stdlib 7.1) gen_server.erl:2470: :gen_server.try_handle_call/4
    (stdlib 7.1) gen_server.erl:2499: :gen_server.handle_msg/3
    (stdlib 7.1) proc_lib.erl:333: :proc_lib.init_p_do_apply/3
Process Label: {:shape_log_collector, "single_stack"}
Last message (from #PID<0.3263.0>): {:handle_event, %Electric.Replication.Changes.TransactionFragment{xid: 51714091, lsn: #Lsn<B/C70A34B0>, last_log_offset: LogOffset.new(50583975088, 0), has_begin?: true, commit: %Electric.Replication.Changes.Commit{commit_timestamp: ~U[2026-02-28 01:42:09.788213Z], transaction_size: 113, txn_change_count: 1}, changes: [%Electric.Replication.Changes.DeletedRecord{relation: {"<schema>", "<tablename>"}, old_record: %{......}, log_offset: LogOffset.new(50583975088, 0), key: nil, move_tags: [], last?: false}], affected_relations: MapSet.new([{"<schema>", "<tablename>"}]), change_count: 1}, {:undefined, %{}}}

Maybe something to do with the materializer for that dependency shape not starting?

Wiping the container's volumes and restarting gets it to work again.

Expected behavior
Expected behavior is to sync that change without crashing.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions