Repository navigation
core: batch expired cache and channel record cleanup - #27587
Merged
Merged
Conversation
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
nalves599
force-pushed
the
nalves599/batch-expired-cache
branch
from
November 4, 2026 11:37
8c7c22e to
41fbf8b
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #27587 +/- ##
==========================================
- Coverage 93.00% 92.96% -0.04%
==========================================
Files 1226 1229 +3
Lines 85235 85689 +454
Branches 4894 4894
==========================================
+ Hits 79270 79665 +395
- Misses 5878 5937 +59
Partials 87 87
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
Signed-off-by: Jens Langhammer <[email protected]>
✅ Deploy Preview for authentik-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for authentik-integrations ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
BeryJu
approved these changes
Nov 5, 2026
Contributor
|
🍒 Cherry-pick to |
BeryJu
added a commit
that referenced
this pull request
Nov 5, 2026
to version-2026.8) (#27634) core: batch expired cache and channel record cleanup (#27587) * core: batch expired cache and channel record cleanup * delete more efficiently --------- Signed-off-by: Jens Langhammer <[email protected]> Co-authored-by: Nuno Alves <[email protected]> Co-authored-by: Jens Langhammer <[email protected]>
kensternberg-authentik
added a commit
that referenced
this pull request
Nov 5, 2026
* main: (313 commits) web/admin: fix ldap source parent group form (#26421) stages/prompt: preserve empty initial values (#25148) core: batch expired cache and channel record cleanup (#27587) web: bump mermaid from 11.16.0 to 12.3.0 in /website (#27598) ci: bump taiki-e/install-action from 2.89.0 to 2.89.1 in /.github/actions/setup (#27630) core: bump goauthentik/fips-python from `d4c46c4` to `69e7058` in /lifecycle/container (#27626) ci: bump AndreKurait/docker-cache from 0.7.0 to 0.7.1 in /.github/actions/setup (#27628) ci: bump actions-rust-lang/setup-rust-toolchain from 2.0.0 to 2.0.1 in /.github/actions/setup (#27629) ci: bump actions-rust-lang/setup-rust-toolchain from 2.0.0 to 2.0.1 (#27627) providers/oauth2: sign tokens with ML-DSA keys (#27172) sources/oauth: verify ML-DSA signed tokens (#27170) web: bump postcss from 8.5.18 to 8.5.32 in /website (#27602) web: bump postcss from 8.5.16 to 8.5.32 in /web (#27604) web/element: fix missing line break between elapsed time and displayed time. (#27624) web/elements: rename ak-codemirror to ak-code-editor (#27406) website/integrations: add Google Cloud Workforce Identity Federation guide (#27571) root: test that FIPS mode refuses non-approved algorithms (#27536) web: bump nanoid from 3.3.16 to 3.3.20 in /website (#27599) web: bump baseline-browser-mapping from 2.10.43 to 2.11.35 in /website (#27600) web: bump mermaid from 11.16.1 to 11.17.2 in /web (#27603) ...
kensternberg-authentik
added a commit
that referenced
this pull request
Nov 5, 2026
* main: (1729 commits) web/admin: fix ldap source parent group form (#26421) stages/prompt: preserve empty initial values (#25148) core: batch expired cache and channel record cleanup (#27587) web: bump mermaid from 11.16.0 to 12.3.0 in /website (#27598) ci: bump taiki-e/install-action from 2.89.0 to 2.89.1 in /.github/actions/setup (#27630) core: bump goauthentik/fips-python from `d4c46c4` to `69e7058` in /lifecycle/container (#27626) ci: bump AndreKurait/docker-cache from 0.7.0 to 0.7.1 in /.github/actions/setup (#27628) ci: bump actions-rust-lang/setup-rust-toolchain from 2.0.0 to 2.0.1 in /.github/actions/setup (#27629) ci: bump actions-rust-lang/setup-rust-toolchain from 2.0.0 to 2.0.1 (#27627) providers/oauth2: sign tokens with ML-DSA keys (#27172) sources/oauth: verify ML-DSA signed tokens (#27170) web: bump postcss from 8.5.18 to 8.5.32 in /website (#27602) web: bump postcss from 8.5.16 to 8.5.32 in /web (#27604) web/element: fix missing line break between elapsed time and displayed time. (#27624) web/elements: rename ak-codemirror to ak-code-editor (#27406) website/integrations: add Google Cloud Workforce Identity Federation guide (#27571) root: test that FIPS mode refuses non-approved algorithms (#27536) web: bump nanoid from 3.3.16 to 3.3.20 in /website (#27599) web: bump baseline-browser-mapping from 2.10.43 to 2.11.35 in /website (#27600) web: bump mermaid from 11.16.1 to 11.17.2 in /web (#27603) ...
kensternberg-authentik
added a commit
that referenced
this pull request
Nov 5, 2026
* main: (28 commits) events: bundle DB-IP Lite GeoIP databases instead of MaxMind GeoLite2 (#27102) web/admin: fix ldap source parent group form (#26421) stages/prompt: preserve empty initial values (#25148) core: batch expired cache and channel record cleanup (#27587) web: bump mermaid from 11.16.0 to 12.3.0 in /website (#27598) ci: bump taiki-e/install-action from 2.89.0 to 2.89.1 in /.github/actions/setup (#27630) core: bump goauthentik/fips-python from `d4c46c4` to `69e7058` in /lifecycle/container (#27626) ci: bump AndreKurait/docker-cache from 0.7.0 to 0.7.1 in /.github/actions/setup (#27628) ci: bump actions-rust-lang/setup-rust-toolchain from 2.0.0 to 2.0.1 in /.github/actions/setup (#27629) ci: bump actions-rust-lang/setup-rust-toolchain from 2.0.0 to 2.0.1 (#27627) providers/oauth2: sign tokens with ML-DSA keys (#27172) sources/oauth: verify ML-DSA signed tokens (#27170) web: bump postcss from 8.5.18 to 8.5.32 in /website (#27602) web: bump postcss from 8.5.16 to 8.5.32 in /web (#27604) web/element: fix missing line break between elapsed time and displayed time. (#27624) web/elements: rename ak-codemirror to ak-code-editor (#27406) website/integrations: add Google Cloud Workforce Identity Federation guide (#27571) root: test that FIPS mode refuses non-approved algorithms (#27536) web: bump nanoid from 3.3.16 to 3.3.20 in /website (#27599) web: bump baseline-browser-mapping from 2.10.43 to 2.11.35 in /website (#27600) ...
kensternberg-authentik
added a commit
that referenced
this pull request
Nov 5, 2026
…b-controller' into web/admin/breadcrumb-controller * refs/remotes/origin/web/admin/breadcrumb-controller: (214 commits) The updated format for crumbs required an update to the unit tests. web/admin: Add a Breadcrumb context manager to the navigation suite Adding the Breadcrumbs visual component. Revised naming code to track certain features. web/elements: vendor sidebar and add icons (#27289) providers/oauth2: don't set state in responses if not supplied (#9735) web/elements: expansion visual hierarchy (#27562) providers/oauth2: accept ML-DSA keys for DPoP (#27174) website/docs: draft 2026.11 release notes (#26814) sources/ldap: store the directory date when resetting a password (#27578) events: bundle DB-IP Lite GeoIP databases instead of MaxMind GeoLite2 (#27102) web/admin: fix ldap source parent group form (#26421) stages/prompt: preserve empty initial values (#25148) core: batch expired cache and channel record cleanup (#27587) web: bump mermaid from 11.16.0 to 12.3.0 in /website (#27598) ci: bump taiki-e/install-action from 2.89.0 to 2.89.1 in /.github/actions/setup (#27630) core: bump goauthentik/fips-python from `d4c46c4` to `69e7058` in /lifecycle/container (#27626) ci: bump AndreKurait/docker-cache from 0.7.0 to 0.7.1 in /.github/actions/setup (#27628) ci: bump actions-rust-lang/setup-rust-toolchain from 2.0.0 to 2.0.1 in /.github/actions/setup (#27629) ci: bump actions-rust-lang/setup-rust-toolchain from 2.0.0 to 2.0.1 (#27627) ...
kensternberg-authentik
added a commit
that referenced
this pull request
Nov 5, 2026
…k-controller * web/admin/breadcrumb-controller: (215 commits) Changes requested by reviewer (@GirlBossRush). The updated format for crumbs required an update to the unit tests. web/admin: Add a Breadcrumb context manager to the navigation suite Adding the Breadcrumbs visual component. Revised naming code to track certain features. web/elements: vendor sidebar and add icons (#27289) providers/oauth2: don't set state in responses if not supplied (#9735) web/elements: expansion visual hierarchy (#27562) providers/oauth2: accept ML-DSA keys for DPoP (#27174) website/docs: draft 2026.11 release notes (#26814) sources/ldap: store the directory date when resetting a password (#27578) events: bundle DB-IP Lite GeoIP databases instead of MaxMind GeoLite2 (#27102) web/admin: fix ldap source parent group form (#26421) stages/prompt: preserve empty initial values (#25148) core: batch expired cache and channel record cleanup (#27587) web: bump mermaid from 11.16.0 to 12.3.0 in /website (#27598) ci: bump taiki-e/install-action from 2.89.0 to 2.89.1 in /.github/actions/setup (#27630) core: bump goauthentik/fips-python from `d4c46c4` to `69e7058` in /lifecycle/container (#27626) ci: bump AndreKurait/docker-cache from 0.7.0 to 0.7.1 in /.github/actions/setup (#27628) ci: bump actions-rust-lang/setup-rust-toolchain from 2.0.0 to 2.0.1 in /.github/actions/setup (#27629) ...
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.
Details
What does this PR change?
Replaces individual deletes with batches of up to 1,000 rows when cleaning up expired PostgreSQL cache entries, messages, and group-channel records.
Each batch runs in a transaction and uses
SELECT FOR UPDATE SKIP LOCKEDto protect against concurrent cache refreshes and avoid waiting on rows locked by other transactions. Skipped rows are left for a later cleanup run.Existing
ExpiringModel.expire_action()hooks and logging levels are preserved. The helper returns the actual number of target-model records deleted.Also replaces
return []withreturninchunked_queryset(), since it is a generator whose return type isNone.Why is this change needed?
Deleting records individually requires many database round trips. With a high-latency PostgreSQL connection,
clean_expired_modelscan exceed its 600-second time limit.Batching reduces those round trips while keeping each transaction bounded.
How was this tested?
git diff --checkpassed.A local benchmark with 2,000 expired cache entries and an injected 10 ms delay per SQL execution produced:
These are simulated-latency results, not production measurements. The full
make allsuite was not run.Linked issues
Refs #26989 for the related cleanup-timeout symptom. This PR does not address the worker connection-recovery problem described there.
Checklist
make all)make docs)