Skip to content

fix(functions): let schedulers skip runs the worker would reject - #14011

Merged
ChiragAgg5k merged 3 commits into
appwrite:mainfrom
ChiragAgg5k:fix/schedule-functions-should-enqueue
Sep 30, 2026
Merged

ChiragAgg5k merged 3 commits into
appwrite:mainfrom
ChiragAgg5k:fix/schedule-functions-should-enqueue

Conversation

@ChiragAgg5k

Copy link
Copy Markdown
Member

What

Adds a protected ScheduleFunctions::shouldEnqueue() hook (default true), checked before each scheduled run is enqueued.

Why

On Cloud, the functions worker's init hook rejects runs for teams over their billing limit. On the Redis broker a rejected job stays on failed.v1-functions with its full payload (~8 KB, no TTL), and nothing retries it. On 2026-09-30 fra1 this reached 259k entries (~2 GB, ~40k/day, 98% scheduled runs), filled queue-dragonfly, and it started evicting live jobs.

Cloud will override the hook to skip runs for teams over their limit, so they are never enqueued. There is no change to self-hosted behaviour.

Rejected jobs stay on the failed list with their payload and are never retried. Cloud needs a seam to drop scheduled runs for teams over their billing limit before they are enqueued.
@ghost

ghost commented Sep 30, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The latest changes preserve fail-open dispatch behavior and introduce no concrete issue requiring a fix.

Adds a protected shouldEnqueue() hook to the function scheduler, defaulting to true, so deployments can skip scheduled runs their worker would reject. The scheduler checks each occurrence before publishing and marks skipped occurrences on its span; a failed check still enqueues the run.

Latest changes: The newest commit moved the fail-open check into dispatch() and records a hook exception as the occurrence span's error.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 1
File Change
src/Appwrite/Platform/Tasks/ScheduleFunctions.php Adds the enqueue eligibility hook, checks each occurrence, and retains fail-open behavior when the hook throws.

Reviewed the commits since a99dde1 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Tier S · Looks good to merge. Summary

@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Adds eligibility check before enqueueing scheduled functions.

The PR appears safe to merge based on the reviewed changes and previous threads.

Summary

The PR adds a default-allow eligibility hook before scheduled function runs are enqueued. The latest change records a failed eligibility check as the occurrence span’s error while still enqueuing the run.

Reviews (3) · Last reviewed commit: "fix(functions): report failed eligibilit..."

@ChiragAgg5k
ChiragAgg5k merged commit 0e60f3a into appwrite:main Sep 30, 2026
56 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the fix/schedule-functions-should-enqueue branch September 30, 2026 10:13
abnegate added a commit that referenced this pull request Sep 30, 2026
Brings in main's OAuth2 state and nonce validation (#14012), which cloud
needs, along with the realtime origin alignment (#14020), subscriber
target ownership (#14019), GitLab primary email (#14010), impersonation
MFA (#14017), write-only webhook passwords (#14016), chunked-upload
resume ownership (#14014), preview authorize validation (#14013),
nightly forcing (#14015) and scheduled-function enqueue checks (#14011).

The merge had no textual conflicts, and main left composer.json and
composer.lock unchanged. So the lock keeps the branch's database and
async pins.

Main's assertResumeAllowed() in Storage Buckets/Files/Create checks
Input(Database::PERMISSION_UPDATE, ...). utopia-php/database 8 has no
PERMISSION_* constants, so every chunked resume would fail with an
undefined-constant error. It now passes PermissionType::Update, as the
rest of that action already does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant