Repository navigation
Base the audit retention custom check on the oldest expired rows - #6208
Draft
ramonsmits wants to merge 1 commit into
Draft
ramonsmits wants to merge 1 commit into
ramonsmits wants to merge 1 commit into
Conversation
The check counted consecutive failed sweeps in memory. A sweep that succeeds but takes longer than the sweep interval, a sweep that does not end and a restart did not fail the check, and the sweep retries reached the count of three in less than a minute. The check reads the oldest expired rows from the database and fails when rows stay more than three hours after their retention period ended.
ramonsmits
force-pushed
the
audit-retention-check-oldest-row
branch
from
November 30, 2026 08:58
e557067 to
130e5f6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The "Audit retention" custom check reads the oldest expired rows from the database. It fails when rows stay more than three hours after their retention period ended.
The check counted consecutive failed sweeps in memory and failed at three. That count misses the cases where the database grows without a failed sweep:
The sweep retries also changed the meaning of the count. Three failures took three hours, and with the retries they take less than a minute.
Changes
IAuditPartitionManager.OldestExpiredreturns the first value ofListExpired. SQL Server overrides it with one seek on the clustered key. PostgreSQL uses the default, which reads the partition names.OldestExpiredfor each kind of row, with the retention period plus a tolerance of three hours. Three hours is three sweep intervals, the same tolerance as the count of three.AuditRetentionCustomCheck.Statekeeps only the reason of the last failed sweep. It does not affect the check result.Notes for the review
Docs: reviewed
docs/telemetry.mdanddocs/message-body-storage.md. Updated the retention section ofdocs/telemetry.mdto describe what the check reads.docs/message-body-storage.mdneeds no change.Guidelines: "Prefer explicit container registration" followed, the check gets its new dependencies through the constructor. "Prefer explicit persistence operations" followed except for one rule:
OldestExpiredtakes theAuditDbContextfrom the caller, as the otherIAuditPartitionManagermethods do. "Prefer Microsoft abstractions" and "Database schema and index changes" do not apply.