Skip to content

packages/django-dramatiq-postgres: reconcile pending tasks during continuous notifications - #26152

Merged
rissson merged 2 commits into
goauthentik:mainfrom
ryanpesek:worker-notification-starvation
Sep 23, 2026
Merged

rissson merged 2 commits into
goauthentik:mainfrom
ryanpesek:worker-notification-starvation

Conversation

@ryanpesek

Copy link
Copy Markdown
Contributor

Details

What does this PR change?

Periodically reconcile runnable tasks from PostgreSQL into the consumer's pending set, even while PostgreSQL notifications continue arriving.

Reconciliation uses the existing consumer_listen_timeout as its interval and does not run while the consumer has reached its prefetch limit.

A regression test covers continuous stale notifications preventing a runnable task from being discovered.

Why is this change needed?

PostgreSQL NOTIFY messages are delivered to every worker. In deployments where workers have different database latency, a lower-latency worker can claim and complete tasks before a higher-latency worker processes the corresponding notifications.

The higher-latency worker then spends its time processing stale notification IDs. Because the broker only queried the task table when no notification was available, a continuous notification stream could prevent that fallback query indefinitely, leaving runnable tasks undiscovered by the worker.

This was reproduced with workers in two regions sharing a PostgreSQL database. Restarting the affected worker caused its startup scan to find the runnable backlog and immediately resume processing at full concurrency.


Checklist

  • The project has been linted, built, and tested (make all)
  • The documentation has been updated and formatted (make docs)
  • I have read the AI usage policy.

@ryanpesek
ryanpesek requested a review from a team as a code owner September 15, 2026 03:19
@netlify

netlify Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit 1a6d114
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/6ab2b99879aa6600083a9f5f
😎 Deploy Preview https://deploy-preview-26152--authentik-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.08%. Comparing base (449f299) to head (1a6d114).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #26152      +/-   ##
==========================================
- Coverage   92.11%   92.08%   -0.04%     
==========================================
  Files        1176     1176              
  Lines       76768    76793      +25     
  Branches     4121     4121              
==========================================
- Hits        70716    70715       -1     
- Misses       5999     6025      +26     
  Partials       53       53              
Flag Coverage Δ
conformance 33.33% <0.00%> (-0.02%) ⬇️
e2e 38.11% <0.00%> (-0.02%) ⬇️
integration 29.64% <0.00%> (-0.46%) ⬇️
rust 44.79% <ø> (ø)
unit 93.61% <100.00%> (+<0.01%) ⬆️
unit-migrate 93.62% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@rissson

rissson commented Sep 22, 2026

Copy link
Copy Markdown
Member

@ryanpesek do you mind resolving the conflicts? and then we can get this in

@ryanpesek

Copy link
Copy Markdown
Contributor Author

@ryanpesek do you mind resolving the conflicts? and then we can get this in

Done!

@rissson
rissson merged commit 5133595 into goauthentik:main Sep 23, 2026
139 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in authentik Core Sep 23, 2026
@BeryJu BeryJu added the backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8 label Nov 23, 2026
@authentik-cherry-pick

Copy link
Copy Markdown
Contributor

🍒 Cherry-pick to version-2026.8 created: #27999

BeryJu pushed a commit that referenced this pull request Nov 23, 2026
…tinuous notifications (cherry-pick #26152 to version-2026.8) (#27999)

packages/django-dramatiq-postgres: reconcile pending tasks during continuous notifications (#26152)

Co-authored-by: Ryan Pesek <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants