@@ -97,6 +97,9 @@ defmodule Electric.Connection.Manager do
97
97
:replication_client_pid ,
98
98
# Timer reference for the periodic replication client status check
99
99
: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? ,
100
103
# PID of the Postgres connection lock
101
104
:lock_connection_pid ,
102
105
# Timer reference for the periodic lock status check
@@ -360,6 +363,7 @@ defmodule Electric.Connection.Manager do
360
363
state = % State {
361
364
state
362
365
| replication_client_pid: pid ,
366
+ replication_client_blocked_by_pending_transaction?: false ,
363
367
current_step: { :start_replication_client , :connecting }
364
368
}
365
369
@@ -532,8 +536,18 @@ defmodule Electric.Connection.Manager do
532
536
"before it can create the replication slot."
533
537
end )
534
538
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
+
535
543
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
+
537
551
{ :noreply , state }
538
552
end
539
553
@@ -843,6 +857,8 @@ defmodule Electric.Connection.Manager do
843
857
state . replication_client_pid
844
858
)
845
859
860
+ state = % { state | replication_client_blocked_by_pending_transaction?: false }
861
+
846
862
case phase do
847
863
:connection_setup ->
848
864
# This is the case where Connection.Manager starts connections from the initial state.
0 commit comments