Skip to content

Conversation

@mafredri
Copy link
Member

@mafredri mafredri commented Dec 1, 2025

Add DeleteOldConnectionLogs query and integrate it into the dbpurge
routine. Retention is controlled by --retention-connection-logs flag.
Disabled (0) by default.

Depends on #21021
Updates #20743


PR Stack

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

@mafredri mafredri force-pushed the mafredri/feat-coderd-db-retention-policy-2 branch from c067a63 to 661866d Compare December 1, 2025 13:31
@mafredri mafredri changed the title feat(dbpurge): add configurable retention for connection logs feat(coderd/database/dbpurge): add retention for connection logs Dec 1, 2025
@mafredri mafredri force-pushed the mafredri/feat-coderd-db-retention-policy-2 branch 2 times, most recently from b8a4bdb to 0fb3b51 Compare December 1, 2025 14:40
@mafredri mafredri force-pushed the mafredri/feat-coderd-db-retention-policy-2 branch from 724b589 to 782f1f7 Compare December 1, 2025 17:00
@mafredri mafredri marked this pull request as ready for review December 1, 2025 18:17
Copy link
Member

@ethanndickson ethanndickson left a comment

Choose a reason for hiding this comment

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

nice! I'm glad we're doing this.

@mafredri mafredri force-pushed the mafredri/feat-coderd-db-retention-policy branch from b34ee61 to d5062e2 Compare December 2, 2025 09:48
@mafredri mafredri force-pushed the mafredri/feat-coderd-db-retention-policy-2 branch from 782f1f7 to 039afdb Compare December 2, 2025 09:59
Base automatically changed from mafredri/feat-coderd-db-retention-policy to main December 2, 2025 14:04
Add `DeleteOldConnectionLogs` query and integrate it into the `dbpurge`
routine. Retention is controlled by `--retention-connection-logs` flag,
falling back to `--retention-global` when not set. Disabled (0) by
default.

Depends on #21021
Updates #20743
Connection logs retention is now explicit - it's enabled when
--connection-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.
Increase from 1000 to 10000 to improve deletion throughput for large
deployments. At 10 minute intervals, this allows purging up to 1.44M
records per day.
@mafredri mafredri force-pushed the mafredri/feat-coderd-db-retention-policy-2 branch from 6433def to d456497 Compare December 2, 2025 14:05
@mafredri mafredri enabled auto-merge (squash) December 2, 2025 14:08
@mafredri mafredri merged commit 9ebcca5 into main Dec 2, 2025
32 checks passed
@mafredri mafredri deleted the mafredri/feat-coderd-db-retention-policy-2 branch December 2, 2025 14:17
@github-actions github-actions bot locked and limited conversation to collaborators Dec 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants