Skip to content

Commit

Permalink
feat: use multicast instead of cast in a loop (#564)
Browse files Browse the repository at this point in the history
  • Loading branch information
hauleth authored Jan 24, 2025
1 parent 2ddbba7 commit 7a4cd70
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.24
2.0.25
3 changes: 1 addition & 2 deletions lib/supavisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ defmodule Supavisor do
end

def terminate_global(tenant) do
[node() | Node.list()]
|> :erpc.multicall(Supavisor, :dirty_terminate, [tenant], 60_000)
:erpc.multicall([node() | Node.list()], Supavisor, :dirty_terminate, [tenant], 60_000)
end

@spec del_all_cache(String.t(), String.t()) :: [map()]
Expand Down
18 changes: 8 additions & 10 deletions lib/supavisor/db_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -673,17 +673,15 @@ defmodule Supavisor.DbHandler do
defp handle_authentication_error(%{proxy: false} = data, reason) do
tenant = Supavisor.tenant(data.id)

for node <- [node() | Node.list()] do
:erpc.cast(node, fn ->
Cachex.del(Supavisor.Cache, {:secrets, tenant, data.user})
Cachex.del(Supavisor.Cache, {:secrets_check, tenant, data.user})

Registry.dispatch(Supavisor.Registry.TenantClients, data.id, fn entries ->
for {client_handler, _meta} <- entries,
do: send(client_handler, {:disconnect, reason})
end)
:erpc.multicast([node() | Node.list()], fn ->
Cachex.del(Supavisor.Cache, {:secrets, tenant, data.user})
Cachex.del(Supavisor.Cache, {:secrets_check, tenant, data.user})

Registry.dispatch(Supavisor.Registry.TenantClients, data.id, fn entries ->
for {client_handler, _meta} <- entries,
do: send(client_handler, {:disconnect, reason})
end)
end
end)

Supavisor.stop(data.id)
end
Expand Down

0 comments on commit 7a4cd70

Please sign in to comment.