Issue #3888
closedApplicability task is scheduled for more profiles than needed
Description
If there are many orphaned applicability profiles, and applicability regeneration is triggered for a repo with many consumers, it can produce a lot of no-op tasks which doesn't produce any value but just load the system.
The suggestion is to not schedule applicability tasks for orphaned applicability profiles.
Orphaned profiles:
- belong to a repo which doesn't exist (those are harmless, since applicability is scheduled for a specific repo_id which should exists)
- applicability profiles for orphaned consumer profiles (consumer profiles which no longer belong to any consumer)
- applicability profiles for existing consumer profiles which no longer belong to a repo for which applicability regeneration is triggered (real-life example - 70K profiles for a repo, 0 bound consumers -> 7K useless tasks). I'm also not sure if this type of orphaned tasks is cleaned up by monthly maintenance task.