Content-Length: 328695 | pFad | http://github.com/electric-sql/electric/commit/6af9f336d653dbd9bf75b10cf3938b07c8f63b93

3E Dispatch a stack event when the replication client is blocked on a pe… · electric-sql/electric@6af9f33 · GitHub
Skip to content

Commit 6af9f33

Browse files
authored
Dispatch a stack event when the replication client is blocked on a pending transaction (#2839)
1 parent 0a99fa4 commit 6af9f33

File tree

1 file changed

+17
-1
lines changed
  • packages/sync-service/lib/electric/connection

1 file changed

+17
-1
lines changed

packages/sync-service/lib/electric/connection/manager.ex

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ defmodule Electric.Connection.Manager do
9797
:replication_client_pid,
9898
# Timer reference for the periodic replication client status check
9999
:replication_client_timer,
100+
# This flag is set whenever the timer that checks the replication client's status trips
101+
# and the client still hasn't finished configuration its connection by then.
102+
:replication_client_blocked_by_pending_transaction?,
100103
# PID of the Postgres connection lock
101104
:lock_connection_pid,
102105
# Timer reference for the periodic lock status check
@@ -360,6 +363,7 @@ defmodule Electric.Connection.Manager do
360363
state = %State{
361364
state
362365
| replication_client_pid: pid,
366+
replication_client_blocked_by_pending_transaction?: false,
363367
current_step: {:start_replication_client, :connecting}
364368
}
365369

@@ -532,8 +536,18 @@ defmodule Electric.Connection.Manager do
532536
"before it can create the replication slot."
533537
end)
534538

539+
if not state.replication_client_blocked_by_pending_transaction? do
540+
dispatch_stack_event(:replication_slot_creation_blocked_by_pending_trasactions, state)
541+
end
542+
535543
tref = schedule_periodic_connection_status_check(:replication_client)
536-
state = %State{state | replication_client_timer: tref}
544+
545+
state = %State{
546+
state
547+
| replication_client_timer: tref,
548+
replication_client_blocked_by_pending_transaction?: true
549+
}
550+
537551
{:noreply, state}
538552
end
539553

@@ -843,6 +857,8 @@ defmodule Electric.Connection.Manager do
843857
state.replication_client_pid
844858
)
845859

860+
state = %{state | replication_client_blocked_by_pending_transaction?: false}
861+
846862
case phase do
847863
:connection_setup ->
848864
# This is the case where Connection.Manager starts connections from the initial state.

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/electric-sql/electric/commit/6af9f336d653dbd9bf75b10cf3938b07c8f63b93

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy