Skip to content

Commit 448171d

Browse files
committed
just fake txids completely
1 parent e8c72ad commit 448171d

File tree

4 files changed

+1
-41
lines changed

4 files changed

+1
-41
lines changed

lib/phoenix/sync/sandbox.ex

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ if Code.ensure_loaded?(Ecto.Adapters.SQL.Sandbox) do
252252

253253
# give the inspector access to the sandboxed connection
254254
Ecto.Adapters.SQL.Sandbox.allow(repo, owner, Sandbox.Inspector.name(stack_id))
255-
:ok = Sandbox.Producer.sync(stack_id)
256255

257256
# mark the stack as ready
258257
Electric.StatusMonitor.mark_pg_lock_acquired(stack_id, owner)

lib/phoenix/sync/sandbox/inspector.ex

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ if Code.ensure_loaded?(Ecto.Adapters.SQL.Sandbox) do
3636
Phoenix.Sync.Sandbox.name({__MODULE__, stack_id})
3737
end
3838

39-
def current_xmax(stack_id) do
40-
GenServer.call(name(stack_id), :current_xmax)
41-
end
42-
4339
@impl GenServer
4440
def init(args) do
4541
{:ok, stack_id} = Keyword.fetch(args, :stack_id)
@@ -73,16 +69,6 @@ if Code.ensure_loaded?(Ecto.Adapters.SQL.Sandbox) do
7369
}
7470
end
7571

76-
def handle_call(:current_xmax, _from, state) do
77-
reply =
78-
with {:ok, %{rows: [[xmax]]}} <-
79-
Postgrex.query(pool(state), "SELECT pg_snapshot_xmax(pg_current_snapshot())", []) do
80-
{:ok, xmax}
81-
end
82-
83-
{:reply, reply, state}
84-
end
85-
8672
defp pool(state) do
8773
%{pid: pool} = Ecto.Adapter.lookup_meta(state.repo.get_dynamic_repo())
8874
pool

lib/phoenix/sync/sandbox/producer.ex

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ if Code.ensure_loaded?(Ecto.Adapters.SQL.Sandbox) do
3333
GenServer.cast(name(stack_id), {:emit_changes, changes})
3434
end
3535

36-
def sync(stack_id) do
37-
GenServer.call(name(stack_id), :sync)
38-
end
39-
4036
def name(stack_id) do
4137
Phoenix.Sync.Sandbox.name({__MODULE__, stack_id})
4238
end
@@ -50,18 +46,6 @@ if Code.ensure_loaded?(Ecto.Adapters.SQL.Sandbox) do
5046
{:ok, state}
5147
end
5248

53-
# get the current xmax from pg so that our change events are properly ordered
54-
# after the initial sync
55-
# has to come after start up and after we've allowed the inspector access to the
56-
# sandboxed connection
57-
def handle_call(:sync, _from, state) do
58-
with {:ok, xmax} <- Phoenix.Sync.Sandbox.Inspector.current_xmax(state.stack_id) do
59-
{:reply, :ok, Map.put(state, :txid, xmax + 1000)}
60-
else
61-
error -> {:reply, error, state}
62-
end
63-
end
64-
6549
def handle_cast({:emit_changes, changes}, %{txid: txid, stack_id: stack_id} = state) do
6650
{msgs, next_txid} =
6751
changes

lib/phoenix/sync/sandbox/stack.ex

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,7 @@ if Code.ensure_loaded?(Ecto.Adapters.SQL.Sandbox) do
4242
Postgrex.transaction(
4343
db_pool,
4444
fn conn ->
45-
# %{rows: [[pg_snapshot]]} = Postgrex.query!(conn, "SELECT pg_current_snapshot()", [])
46-
47-
%{rows: [[xmin, xmax]]} =
48-
Postgrex.query!(
49-
conn,
50-
"SELECT pg_snapshot_xmin(pg_current_snapshot()), pg_snapshot_xmax(pg_current_snapshot())",
51-
[]
52-
)
53-
54-
GenServer.cast(parent, {:pg_snapshot_known, shape_handle, {xmin, xmax, []}})
45+
GenServer.cast(parent, {:pg_snapshot_known, shape_handle, {1000, 1100, []}})
5546

5647
# Enforce display settings *before* querying initial data to maintain consistent
5748
# formatting between snapshot and live log entries.

0 commit comments

Comments
 (0)