Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(coderd/database/dbpurge): add retention for audit logs#21025

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
mafredri wants to merge5 commits intomafredri/feat-coderd-db-retention-policy-2
base:mafredri/feat-coderd-db-retention-policy-2
Choose a base branch
Loading
frommafredri/feat-coderd-db-retention-policy-3

Conversation

@mafredri
Copy link
Member

@mafredrimafredri commentedDec 1, 2025
edited by dannykopping
Loading

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

PRTitle
#21021feat(coderd): add retention policy configuration
#21022feat(coderd/database/dbpurge): add retention for connection logs
👉#21025feat(coderd/database/dbpurge): add retention for audit logs
#21037feat(coderd/database/dbpurge): make API keys retention configurable
#21038docs: add data retention documentation
#21039feat: add retention config forworkspace_agent_logs

@mafredrimafredriforce-pushed themafredri/feat-coderd-db-retention-policy-3 branch 2 times, most recently from07ae594 to9ca58c3CompareDecember 1, 2025 18:07
@mafredrimafredri marked this pull request as ready for reviewDecember 1, 2025 18:18
@mafredrimafredriforce-pushed themafredri/feat-coderd-db-retention-policy-2 branch from782f1f7 to039afdbCompareDecember 2, 2025 09:59
@mafredrimafredriforce-pushed themafredri/feat-coderd-db-retention-policy-3 branch from9ca58c3 toa21395aCompareDecember 2, 2025 10:02
Copy link
Contributor

@dannykoppingdannykopping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM, except for batch size; I won't need to re-review.

// locks that could impact concurrent database operations.
connectionLogsBatchSize=1000
// Batch size for audit log deletion.
auditLogsBatchSize=1000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

For a sufficiently large deployment, would this even be able to keep up? 1000 entries every 10m would probably not be enough. Deletes are pretty quick and have granular locks, so I'd say go far more aggressive than this.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

That's fair criticism. I could just bump this to 10k, or in a follow-up PR implement one of the following:

  1. If the backlog is >100% batch size, decrease wait time (say, 10m -> 5s)
  2. Check backlog and adjust batch size accordingly (catch-up within N time)

I'd also want to update the dbpurge to not run all deletes in one single transaction as well, but given the lock/replica sync it's a bit tricky.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I don't think we need anything sophisticated like that which breaks predictability.
10K per tick should be fine, even for large installations.

Once we havecoder/internal#1139, and we include the total number of records to be purged, operators could see if purge is not keeping up.

For now I think it's easy enough to just add a 0 and call it a day.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Nice, wasn't aware of that issue 👍🏻

Add configurable retention policy for audit logs. The DeleteOldAuditLogsquery 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#21021Updates#20743
Audit logs retention is now explicit - it's enabled when--audit-logs-retention is set to a non-zero duration, anddisabled when set to 0. No fallback to global retention.
Use :execrows instead of :one to simplify the query by removing theextra CTE wrapper. This lets PostgreSQL return the row count directlyvia RowsAffected() instead of requiring an explicit COUNT(*) scan.
@mafredrimafredriforce-pushed themafredri/feat-coderd-db-retention-policy-3 branch froma21395a to82f1c2bCompareDecember 2, 2025 11:37
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@dannykoppingdannykoppingdannykopping approved these changes

@EmyrkEmyrkAwaiting requested review from Emyrk

Assignees

@mafredrimafredri

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@mafredri@dannykopping

[8]ページ先頭

©2009-2025 Movatter.jp