realtime icon indicating copy to clipboard operation
realtime copied to clipboard

Janitor retains failed maintenance tasks in state

Open hsusul opened this issue 2 months ago • 1 comments

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 main at 1aec648a
  • Elixir 1.19.5
  • OTP 28

hsusul avatar Sep 03 '26 15:09 hsusul

: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:

realtime-release-bot avatar Sep 04 '26 02:09 realtime-release-bot