Skip to content

Upgrade Appwrite to queue 5 and migrate worker configuration #13813

Closed

Description

@loks0n

Upgrade Appwrite from queue 4 to queue 5, preserving worker concurrency and deployment configuration. Make this one focused dependency/API migration PR; measure larger prefetch separately.

Baseline and dependencies

Inspected Appwrite main at f2f494fdfe96381ba75a95438680dcbc5c3b20c8 and utopia-php/monorepo PR #316 at 3addb37842220b3da46691d4d04291762dc5d837 on 2026-09-21.

  • Appwrite #13809 already upgraded to queue 4.0.0 and Platform 1.0.0-rc22. composer.json requires queue ^4.0.0 and pins that Platform release; composer.lock agrees.
  • Monorepo #316 must merge and publish queue 5 plus its compatible Platform release. Use the actual published Platform version; do not guess the next RC or merge development constraints.
  • Appwrite's worker harness currently uses Redis with a dedicated receive connection and a locked command connection. Preserve this arrangement. NATS is a downstream Cloud validation requirement, not a new Appwrite transport feature.
  • Existing follow-on: Cloud #5998, tracked by stats-usage batching #5996.

Implementation: one PR

  • Update composer.json to queue ^5.0.0 and the released compatible Platform version. Regenerate composer.lock with a targeted update, inspecting every transitive change. Do not include unrelated upgrades or change PHP requirements.
  • Rename worker metadata and PHP variables from maxCoroutines to coroutines in app/config/workers.php, src/Appwrite/Workers/Jobs.php, app/worker.php, and associated PHPDoc/comments.
  • Rename the mail/notification pool sizing reads in app/init/registers.php too. Leaving these behind silently changes pool capacity. Update stale descriptions in app/init/configs.php where present.
  • Keep _APP_WORKER_MAX_COROUTINES as the existing external environment variable. Preserve combined-mode per-queue caps, dedicated-mode overrides, and the databases override exclusion. Preserve all configured values, including stats-usage=8 and databases=1. Do not rename deployment variables in this PR.
  • Let omitted prefetch default to the effective coroutine count. No new environment variable, per-worker prefetch table, or blanket prefetch=100. This changes the receive window for concurrent workers, so validate it explicitly; it does not increase handler concurrency. Startup output should show the effective coroutine and prefetch counts.
  • Update direct adapter specifications in tests/e2e/General/WorkerConcurrencyTest.php to coroutines/prefetch. Remove the helper's old implicit batch=1; it would be invalid when coroutines>1 if blindly renamed. Where both old values were explicit, preserve the prior effective outstanding bound with max(oldBatch, coroutines).
  • Update tests/unit/Workers/{JobsTest,InitJobsTest}.php and tests/unit/Platform/Workers/RegistrationTest.php for the new metadata keys and default prefetch behavior.
  • Delete tests/extensions/Queue/InMemoryConnection.php after moving its sole caller, WorkerConcurrencyTest, to the real Redis service. Use a unique namespace per test and separate receive/locked command connections through a factory, as production does. Clean up only that test's keys. Do not recreate Lua in a PHP fake or add a no-op execute(). This removes roughly 250 lines of fake infrastructure.
  • Remove obsolete optional queue-priority arguments from tests/unit/Event/MockPublisher.php. Audit queue publishers for removed priority calls. No production queue-priority calls were found in this snapshot; messaging push priority is a different domain and stays unchanged.

No new domain classes, compatibility wrapper, receipt abstraction, or Appwrite-side broker implementation is needed.

Validation and acceptance

  • Composer validate/install from the lock and changed-file Pint/PHPStan pass. Search confirms no stale queue maxCoroutines/batch metadata or removed queue-priority API calls. The existing environment variable is an intentional exception.
  • Existing JobsTest, InitJobsTest, RegistrationTest and affected event/publisher tests pass; verify dedicated overrides, combined caps, and mail pool sizing remain correct.
  • WorkerConcurrencyTest passes against real Redis: databases has at most one active handler within its worker, other queues retain their own concurrency, all expected messages complete, and a second database message stays in the broker at default prefetch=1. Do not describe a per-process cap as a fleet-wide lock.
  • Add a meaningful case with prefetch greater than coroutines, alongside a database queue, proving independent capacity and no lost work. Exercise graceful shutdown with waiting work: unstarted messages return without consuming a retry attempt and remain consumable after restart.
  • Smoke-test combined and dedicated Compose workers using existing Redis authentication settings. Verify idle maintenance still runs with blocking receive, failed jobs can be retried, and long-running jobs settle successfully. Reuse upstream broker regression coverage rather than duplicate the full Lua test suite here.
  • Demonstrate queue-4-produced ready payloads are consumed by queue 5 and queue-5-produced ready payloads by queue 4, with unchanged JSON encoding/namespace. Test reservation recovery and the rollback procedure on an isolated Redis instance.
  • Run Appwrite CI and representative database schema, function/build, mail, and usage end-to-end paths. Confirm usage totals/error behavior as well as throughput; higher prefetch can change callback ordering around confirmation.

Deployment and rollback

  1. Release queue 5 and compatible Platform, merge this Appwrite migration after its checks, then publish the Appwrite version/reference required by Cloud. Update Cloud's own package constraints/lock and coroutines/prefetch call sites in Fix Migrations Stability #5998. Gate Cloud on Redis/Dragonfly and NATS staging tests; this plan does not claim those tests have run.
  2. Keep queue names, namespaces, codecs, coroutine values and transport routing unchanged. Appwrite's standard standalone Redis deployment needs no queue-key renaming. Any Redis Cluster deployment without a common namespace hash tag needs its own explicit drain/key migration before using these atomic scripts.
  3. Prefer an orderly worker replacement for the initial canary: stop old receives and let running work settle before starting the replacement consumers for that queue. Ready backlog may remain. Prove mixed-version consumer/maintenance behavior in staging before relying on an overlapping rollout. Keep database worker replica counts unchanged.
  4. Observe completion rate, backlog age, processing/reservation accumulation, acknowledgement errors, retries/dead letters, worker memory and shutdown duration. Stop expansion for missing work, incorrect usage totals, persistent settlement errors or unrecovered reservations. Compare against a recorded baseline.
  5. Before rollback, stop new receives, drain running work, and recover expired reservations using queue 5 maintenance while its code remains available. Verify each affected <namespace>.reservations.<queue> index and associated reservation state is empty and processing work is accounted for before starting old workers. Queue 4 can read ready payloads but cannot recover queue 5 reservation lists. Reducing prefetch to one is not a rollback procedure.
  6. Audit priority use in downstream deployments before their upgrade: old NATS priority subjects must be drained with old consumers; new consumers do not read them. Stock Appwrite's inspected Redis publisher paths do not request priority.
  7. Only after the migration is stable, compare larger prefetch settings on a representative workload in Feat target controllers account user #5996. Keep concurrency fixed during that experiment. Do not bundle codec, transport or persistence changes with it.

Plan only: no Appwrite source/dependency changes or migration tests have been executed for this issue. Implementation can be prepared now; merge/release is blocked on the package releases above.

Activity

  1. self-assigned this
    on Sep 21, 2026
  2. added
    product / auth
    product / avatars
    product / databases
    product / domains
    product / functions
    product / messaging
    product / migrations
    product / sites
    product / storage
    product / vcs
    on Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

product / authproduct / avatarsproduct / databasesproduct / domainsproduct / functionsproduct / messagingproduct / migrationsproduct / sitesproduct / storageproduct / vcs

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions