Skip to content

feat(retention): limit data:retention to 500 members per run (--limit) - #587

Open
Neophytis wants to merge 2 commits into
mainfrom
neophytis/data-retention-batch-limit
Open

Neophytis wants to merge 2 commits into
mainfrom
neophytis/data-retention-batch-limit

Conversation

@Neophytis

@Neophytis Neophytis commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Target branch: main. Part of BeWelcome/sysadmins-infra#693 (sustainable rate for deletes, plan section 8.4).

Why

data:retention (cron 00:10 daily) anonymises every qualifying member in one run: AskToLeave, more than a year without login, not yet retired_. It flushes once per member and has no limit.

Today that is a handful per night. But if a deletion policy (to be decided at the GA in November) moves thousands of long-suspended members to AskToLeave at once (83,740 members carry the 5-year suspension marker), that night's run would load the prod DB for hours, during normal use.

Change

  • New option --limit (default 500, 0 = no limit).
  • MemberRepository::loadDataRetentionMembers(int $limit = 0): ORDER BY id, plus setMaxResults when a limit is given.
  • Cleaned members are renamed retired_<id>, which drops them out of the query, so the rest follow on the next nights. Nobody is processed twice.
  • When the limit is reached, a note says the remainder is cleaned on the next run.
  • Cron line unchanged (bin/console data:retention), so the default applies.

Tests

  • php -l clean on both files.
  • Stage check pending. leopard-stage is in use by another e2e test right now. Afterwards: run bin/console data:retention --limit 2 on stage and check that the output stops at 2 with the note, then rerun and check the next members are picked.

data:retention (cron 00:10 daily) anonymises every qualifying AskToLeave
member in one run, with one flush per member. If a deletion policy ever
moves thousands of members to AskToLeave at once, that night's run would
load the prod DB for hours. Now it cleans at most --limit members per run
(default 500, 0 = no limit), oldest id first; cleaned members are renamed
retired_<id> and drop out of the query, so the rest follow on the next
nights. Cron line unchanged. (BeWelcome/sysadmins-infra#654, plan 8.4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement theme:bw-platform Everything related to migrating the platform part of Lion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant