feat(coderd/database/dbpurge): add retention for audit logs - #21025
Merged
Merged
Conversation
This was referenced Dec 1, 2025
mafredri
force-pushed
the
mafredri/feat-coderd-db-retention-policy-3
branch
2 times, most recently
from
December 1, 2025 18:07
07ae594 to
9ca58c3
Compare
mafredri
marked this pull request as ready for review
December 1, 2025 18:18
mafredri
force-pushed
the
mafredri/feat-coderd-db-retention-policy-2
branch
from
December 2, 2025 09:59
782f1f7 to
039afdb
Compare
mafredri
force-pushed
the
mafredri/feat-coderd-db-retention-policy-3
branch
from
December 2, 2025 10:02
9ca58c3 to
a21395a
Compare
dannykopping
approved these changes
Dec 2, 2025
dannykopping
left a comment
Contributor
There was a problem hiding this comment.
LGTM, except for batch size; I won't need to re-review.
mafredri
force-pushed
the
mafredri/feat-coderd-db-retention-policy-3
branch
from
December 2, 2025 11:37
a21395a to
82f1c2b
Compare
mafredri
force-pushed
the
mafredri/feat-coderd-db-retention-policy-3
branch
from
December 2, 2025 12:56
82f1c2b to
2ce8f62
Compare
Member
Author
|
@dannykopping @Emyrk I've bumped to 10k for both audit and connection logs 👍🏻 |
mafredri
force-pushed
the
mafredri/feat-coderd-db-retention-policy-2
branch
from
December 2, 2025 14:05
6433def to
d456497
Compare
mafredri
force-pushed
the
mafredri/feat-coderd-db-retention-policy-3
branch
from
December 2, 2025 14:13
2ce8f62 to
8cb020d
Compare
Base automatically changed from
mafredri/feat-coderd-db-retention-policy-2
to
main
December 2, 2025 14:17
Add configurable retention policy for audit logs. The DeleteOldAuditLogs query excludes deprecated connection events (connect, disconnect, open, close) which are handled separately by DeleteOldAuditLogConnectionEvents. Falls back to global retention if audit logs retention is unset. Disabled (0) by default. Depends on #21021 Updates #20743
Audit logs retention is now explicit - it's enabled when --audit-logs-retention is set to a non-zero duration, and disabled when set to 0. No fallback to global retention.
Use :execrows instead of :one to simplify the query by removing the extra CTE wrapper. This lets PostgreSQL return the row count directly via RowsAffected() instead of requiring an explicit COUNT(*) scan.
mafredri
force-pushed
the
mafredri/feat-coderd-db-retention-policy-3
branch
from
December 2, 2025 14:18
8cb020d to
2a45adb
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Add configurable retention policy for audit logs. The DeleteOldAuditLogs
query excludes deprecated connection events (connect, disconnect, open,
close) which are handled separately by DeleteOldAuditLogConnectionEvents.
Disabled (0) by default.
Depends on #21021
Updates #20743
PR Stack
workspace_agent_logs