Skip to content

Commit a3818b0

Browse files
authored
fix: remove replication_slot_lag_check feature flag (#1911)
1 parent afbedfd commit a3818b0

2 files changed

Lines changed: 3 additions & 36 deletions

File tree

lib/realtime/tenants/replication_connection/watchdog.ex

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ defmodule Realtime.Tenants.ReplicationConnection.Watchdog do
1212
use GenServer
1313
use Realtime.Logs
1414
alias Realtime.Database
15-
alias Realtime.FeatureFlags
1615
alias Realtime.Tenants.Connect
1716
alias Realtime.Tenants.ReplicationConnection
1817

@@ -94,13 +93,9 @@ defmodule Realtime.Tenants.ReplicationConnection.Watchdog do
9493
defp check_slot_lag(%{replication_slot_name: nil}), do: :ok
9594

9695
defp check_slot_lag(%{tenant_id: tenant_id, replication_slot_name: slot_name}) do
97-
if FeatureFlags.enabled?("replication_slot_lag_check", tenant_id) do
98-
case Connect.get_status(tenant_id) do
99-
{:ok, conn} -> Database.check_replication_slot_lag(conn, slot_name)
100-
{:error, reason} -> {:error, reason}
101-
end
102-
else
103-
:ok
96+
case Connect.get_status(tenant_id) do
97+
{:ok, conn} -> Database.check_replication_slot_lag(conn, slot_name)
98+
{:error, reason} -> {:error, reason}
10499
end
105100
end
106101
end

test/realtime/tenants/replication_connection/watchdog_test.exs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ defmodule Realtime.Tenants.ReplicationConnection.WatchdogTest do
66
import ExUnit.CaptureLog
77

88
alias Realtime.Database
9-
alias Realtime.FeatureFlags
109
alias Realtime.Tenants.Connect
1110
alias Realtime.Tenants.ReplicationConnection.Watchdog
1211

@@ -159,7 +158,6 @@ defmodule Realtime.Tenants.ReplicationConnection.WatchdogTest do
159158
end
160159

161160
test "continues when slot lag is below threshold", %{fake_pid: fake_pid} do
162-
stub(FeatureFlags, :enabled?, fn _flag, _tenant -> true end)
163161
stub(Connect, :get_status, fn _tenant_id -> {:ok, :fake_conn} end)
164162
stub(Database, :check_replication_slot_lag, fn _conn, _slot -> :ok end)
165163

@@ -173,7 +171,6 @@ defmodule Realtime.Tenants.ReplicationConnection.WatchdogTest do
173171
replication_slot_name: "test_slot"}
174172
)
175173

176-
Mimic.allow(FeatureFlags, self(), watchdog_pid)
177174
Mimic.allow(Connect, self(), watchdog_pid)
178175
Mimic.allow(Database, self(), watchdog_pid)
179176

@@ -183,7 +180,6 @@ defmodule Realtime.Tenants.ReplicationConnection.WatchdogTest do
183180
end
184181

185182
test "stops with :slot_lag_too_high when lag exceeds threshold", %{fake_pid: fake_pid} do
186-
stub(FeatureFlags, :enabled?, fn _flag, _tenant -> true end)
187183
stub(Connect, :get_status, fn _tenant_id -> {:ok, :fake_conn} end)
188184
stub(Database, :check_replication_slot_lag, fn _conn, _slot -> {:error, :lag_too_high} end)
189185

@@ -199,7 +195,6 @@ defmodule Realtime.Tenants.ReplicationConnection.WatchdogTest do
199195
replication_slot_name: "test_slot"}
200196
)
201197

202-
Mimic.allow(FeatureFlags, self(), watchdog_pid)
203198
Mimic.allow(Connect, self(), watchdog_pid)
204199
Mimic.allow(Database, self(), watchdog_pid)
205200

@@ -211,7 +206,6 @@ defmodule Realtime.Tenants.ReplicationConnection.WatchdogTest do
211206
end
212207

213208
test "continues when DB connection is unavailable (graceful degradation)", %{fake_pid: fake_pid} do
214-
stub(FeatureFlags, :enabled?, fn _flag, _tenant -> true end)
215209
stub(Connect, :get_status, fn _tenant_id -> {:error, :tenant_database_unavailable} end)
216210

217211
logs =
@@ -226,7 +220,6 @@ defmodule Realtime.Tenants.ReplicationConnection.WatchdogTest do
226220
replication_slot_name: "test_slot"}
227221
)
228222

229-
Mimic.allow(FeatureFlags, self(), watchdog_pid)
230223
Mimic.allow(Connect, self(), watchdog_pid)
231224

232225
Process.sleep(120)
@@ -236,26 +229,5 @@ defmodule Realtime.Tenants.ReplicationConnection.WatchdogTest do
236229

237230
assert logs =~ "ReplicationSlotLagCheckSkipped"
238231
end
239-
240-
test "skips lag check when feature flag is disabled", %{fake_pid: fake_pid} do
241-
stub(FeatureFlags, :enabled?, fn _flag, _tenant -> false end)
242-
reject(&Database.check_replication_slot_lag/2)
243-
244-
watchdog_pid =
245-
start_supervised!(
246-
{Watchdog,
247-
parent_pid: fake_pid,
248-
tenant_id: "lag-test",
249-
watchdog_interval: 50,
250-
watchdog_timeout: 100,
251-
replication_slot_name: "test_slot"}
252-
)
253-
254-
Mimic.allow(FeatureFlags, self(), watchdog_pid)
255-
256-
Process.sleep(120)
257-
258-
assert Process.alive?(watchdog_pid)
259-
end
260232
end
261233
end

0 commit comments

Comments
 (0)