Janitor retains failed maintenance tasks in state
Summary
The tenant Janitor retains failed maintenance task references in its GenServer state after receiving a terminal :DOWN message.
Successful tasks are removed with Map.pop/2, but the :killed handler reads the tenants with Map.get/2 and writes the unchanged task map back to state. Other non-normal exit reasons fall through to the catch-all handler and are retained as well.
Because every scheduled run merges new task refs into this map, repeated maintenance failures can grow the Janitor state indefinitely and retain each associated tenant batch.
Reproduction
ref = make_ref()
state = %Realtime.Tenants.Janitor{tasks: %{ref => ["tenant"]}}
{:noreply, result} =
Realtime.Tenants.Janitor.handle_info(
{:DOWN, ref, :process, self(), :killed},
state
)
Map.has_key?(result.tasks, ref)
#=> true
Expected behavior
Any tracked task should be removed from state.tasks when its terminal :DOWN message arrives, whether it completed normally or failed.
Environment
- Realtime
mainat 1aec648a - Elixir 1.19.5
- OTP 28
:tada: This issue has been resolved in version 2.134.3 :tada:
The release is available on GitHub release
Your semantic-release bot :package::rocket: