Fix retention policy deletion-limit stop propagation - #11262
Fix retention policy deletion-limit stop propagation#11262Darrick (darjoo) wants to merge 2 commits into
Conversation
Return EndCurrentRun through the temporary retention policy setup record so background processing stops after the deletion-limit event. Preserve per-policy error isolation and cover limit boundaries, continued processing below the limit, policy errors, and subsequent runs. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Good Sense Reviewer - Round 1Recommendation: Request ChangesWhat this PR doesThis change carries the retention run stop flag back from the isolated child codeunit to the outer automatic loop. It uses the same temporary setup record pattern that already carries the deleted-record count, so the product fix is narrow and aimed at the right boundary. The product code imports the flag only after a successful child run, which keeps per-policy error isolation. The added tests cover the right scenarios, but they currently fail during setup, so the PR is not merge-ready yet. Problem-solution fitFit: Strong The reported problem is that automatic retention processing can continue to later policies after the deletion limit is reached. The code change returns the missing stop state to the loop that owns the stop condition, without changing the deletion limit or event contract. SuggestionsS1 (🔴 High): Refresh allowed tables before creating setup Risk assessment and necessityRisk: The product change is limited to retention policy background processing and an internal transport field. The main risk is merge readiness: the regression tests that should protect this data-deletion path fail before they exercise the changed behavior. Necessity: The change is needed because an exhausted deletion budget should stop the current automatic run instead of processing later policies and raising repeated limit events. The scope is appropriate, but the failing test setup must be fixed before merge.
|
Register the retention-policy test tables with the existing allowed-table refresh helper before creating policies in the new regression tests. Fresh unit-test companies do not have the install-time fixture data. Keep all assertions, production behavior, and CI checks unchanged. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
What & why
Background retention runs execute each policy in an isolated
Codeunit.Runcall. The child returns the cumulative deletion count but losesEndCurrentRun, so the outer loop continues processing later policies and can raise additional limit events after the batch should have stopped.Return the stop flag through the temporary retention policy setup record alongside the deletion count, and import it only after successful child execution. This preserves per-policy error isolation while allowing the existing outer-loop stop condition to take effect.
Linked work
AB#649569
Azure DevOps Bug 649569: Retention policies continue past the deletion limit because EndCurrentRun is not propagated
Approved GitHub issue: not provided; the source work item is in Azure DevOps.
How I validated this
What I tested and the outcome (required - be specific: scenarios, commands, screenshots for UI changes)
git diff --checkpassed.Risk & compatibility
End Current Run, toRetention Policy Setupfor temporary result transport, following the existing deletion-count field pattern. Existing setup records are not rewritten by the execution path.ApplyAllRetentionPoliciescontext propagation is a separate follow-up and is not included here. This change does not redesign scheduling/fairness or guarantee a hard cap for custom or indirect-permission deletion implementations.