From f9efb92b7d67e9079f66a3227a5f4fd667755b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20Caba=C3=A7o?= Date: Thu, 20 Feb 2025 09:59:12 +0000 Subject: [PATCH 1/2] fix: Reduce janitor scope to only local tenants --- lib/realtime/tenants/janitor.ex | 2 +- mix.exs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/realtime/tenants/janitor.ex b/lib/realtime/tenants/janitor.ex index e89e9f134..8869efa3f 100644 --- a/lib/realtime/tenants/janitor.ex +++ b/lib/realtime/tenants/janitor.ex @@ -65,7 +65,7 @@ defmodule Realtime.Tenants.Janitor do Logger.info("Janitor started") %{chunks: chunks, tasks: tasks} = state all_tenants = :ets.select(@table_name, [{{:"$1"}, [], [:"$1"]}]) - connected_tenants = :ets.select(@syn_table, [{{:"$1", :_, :_, :_, :_, :_}, [], [:"$1"]}]) + connected_tenants = :ets.select(@syn_table, [{{:"$1", :_, :_, :_, :_, Node.self()}, [], [:"$1"]}]) new_tasks = MapSet.new(all_tenants ++ connected_tenants) diff --git a/mix.exs b/mix.exs index 9a83d6bbf..a9ddaed99 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule Realtime.MixProject do def project do [ app: :realtime, - version: "2.34.25", + version: "2.34.26", elixir: "~> 1.17.3", elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod, From 4cbe660766feef8db1209d909cd8d853bbe6a939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20Caba=C3=A7o?= Date: Thu, 20 Feb 2025 11:03:53 +0000 Subject: [PATCH 2/2] improve matchspec --- lib/realtime/tenants/janitor.ex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/realtime/tenants/janitor.ex b/lib/realtime/tenants/janitor.ex index 8869efa3f..1a41897f7 100644 --- a/lib/realtime/tenants/janitor.ex +++ b/lib/realtime/tenants/janitor.ex @@ -65,7 +65,9 @@ defmodule Realtime.Tenants.Janitor do Logger.info("Janitor started") %{chunks: chunks, tasks: tasks} = state all_tenants = :ets.select(@table_name, [{{:"$1"}, [], [:"$1"]}]) - connected_tenants = :ets.select(@syn_table, [{{:"$1", :_, :_, :_, :_, Node.self()}, [], [:"$1"]}]) + + connected_tenants = + :ets.select(@syn_table, [{{:"$1", :_, :_, :_, :_, :"$2"}, [{:==, :"$2", {:const, Node.self()}}], [:"$1"]}]) new_tasks = MapSet.new(all_tenants ++ connected_tenants)