electric-sql / electric

Sync little subsets of your Postgres data into local apps and services.
https://electric-sql.com
Apache License 2.0
6.49k stars 156 forks source link

Timeout waiting for snapshot #1438

Open balegas opened 3 months ago

balegas commented 3 months ago

Had to throw enough (large) initial query requests to trigger it. In my case 10 init requests for issue table with 100000 issues.

14:15:31.813 [error] GenServer #PID<0.593.0> terminating
** (stop) exited in: GenServer.call(Electric.ShapeCache, {:wait_for_snapshot, "50159385-1722604526811"}, 5000)
    ** (EXIT) time out
    (elixir 1.17.2) lib/gen_server.ex:1128: GenServer.call/3
    (electric 0.2.4) lib/electric/shapes.ex:16: Electric.Shapes.get_snapshot/2
    (electric 0.2.4) lib/electric/plug/serve_shape_plug.ex:275: Electric.Plug.ServeShapePlug.serve_log_or_snapshot/2
    (electric 0.2.4) lib/electric/plug/serve_shape_plug.ex:1: Electric.Plug.ServeShapePlug.plug_builder_call/2
    (electric 0.2.4) deps/plug/lib/plug/router.ex:246: anonymous fn/4 in Electric.Plug.Router.dispatch/2
    (telemetry 1.2.1) /Users/vbalegas/workspace/electric-next/packages/sync-service/deps/telemetry/src/telemetry.erl:321: :telemetry.span/3
    (electric 0.2.4) deps/plug/lib/plug/router.ex:242: Electric.Plug.Router.dispatch/2
    (electric 0.2.4) lib/electric/plug/router.ex:1: Electric.Plug.Router.plug_builder_call/2
    (bandit 1.5.5) lib/bandit/pipeline.ex:124: Bandit.Pipeline.call_plug!/2
    (bandit 1.5.5) lib/bandit/pipeline.ex:36: Bandit.Pipeline.run/4
    (bandit 1.5.5) lib/bandit/http1/handler.ex:12: Bandit.HTTP1.Handler.handle_data/3
    (bandit 1.5.5) lib/bandit/delegating_handler.ex:18: Bandit.DelegatingHandler.handle_data/3
    (bandit 1.5.5) /Users/vbalegas/workspace/electric-next/packages/sync-service/deps/thousand_island/lib/thousand_island/handler.ex:411: Bandit.DelegatingHandler.handle_continue/2
    (stdlib 6.0.1) gen_server.erl:2163: :gen_server.try_handle_continue/3
    (stdlib 6.0.1) gen_server.erl:2072: :gen_server.loop/7
    (stdlib 6.0.1) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
Last message: {:continue, :handle_connection}
State: {%ThousandIsland.Socket{socket: #Port<0.31>, transport_module: ThousandIsland.Transports.TCP, read_timeout: 60000, silent_terminate_on_error: false, span: %ThousandIsland.Telemetry{span_name: :connection, telemetry_span_context: #Reference<0.2444882864.3121348609.34537>, start_time: -576459997808452298, start_metadata: %{telemetry_span_context: #Reference<0.2444882864.3121348609.34537>, parent_telemetry_span_context: #Reference<0.2444882864.3121086471.156515>, remote_address: {127, 0, 0, 1}, remote_port: 50380}}}, %{opts: %{http: [], http_1: [], http_2: [], websocket: []}, plug: {Electric.Plug.Router, [storage: {Electric.ShapeCache.CubDbStorage, %{file_path: "./shapes", db: :shape_db}}, registry: Registry.ShapeChanges, shape_cache: {Electric.ShapeCache, []}, inspector: {Electric.Postgres.Inspector.EtsInspector, [server: Electric.Postgres.Inspector.EtsInspector]}, long_poll_timeout: 20000, max_age: 1, stale_age: 3, allow_shape_deletion: true]}, handler_module: Bandit.InitialHandler, http_1_enabled: true, http_2_enabled: true}}
balegas commented 3 months ago

@robacourt would be nice to produce some graphs after yours new streaming approach.

icehaunter commented 3 months ago

Before PR: image

After PR: image

Overall: