Skip to content

chore(queue): move to utopia-php/queue 3.0 - #13762

Merged
levivannoort merged 5 commits into
mainfrom
feat/queue-3
Sep 18, 2026
Merged

levivannoort merged 5 commits into
mainfrom
feat/queue-3

Conversation

@levivannoort

Copy link
Copy Markdown
Member

Moves the queue floor to 3.0.0, and platform to 1.0.0-rc21 with it.

Why platform moves too

platform 1.0.0-rc20 requires queue ^2.0.0, so the major cannot resolve through it. rc21 (utopia-php/monorepo#301) widens that constraint and passes a job spec's batch through to Server::job() — without it the batch parameter is unreachable from any application, since every worker boots through Platform::initWorker().

The breaking surface here

queue 3.0 adds rightPopMany() and incrementBy() to Connection. tests/extensions/Queue/InMemoryConnection.php is the only implementation in this repository and now carries both. Consumer is unchanged, so FakeConsumer in InitJobsTest needed nothing.

Nothing in src/ or app/ implements either interface — app/init/registers.php constructs Connection\\Redis and Broker\\Redis, both of which the package ships.

What 3.0 brings that this does not yet use

PermanentFailure (a handler ends a message's life instead of spending its whole redelivery budget on work that cannot succeed), a pluggable envelope codec with the format named in a Content-Type header, and batched receive — one BLMPOP for the wait and the batch. This commit moves the floor so applications built on server-ce can take them up; appwrite/cloud is the first.

Verification

  • WorkerConcurrencyTest (the suite that drives InMemoryConnection) — 3 tests, 8 assertions, green against 3.0.0 on PHP 8.5 with Swoole.
  • tests/unit/Workers/InitJobsTest.php — 2 tests, 5 assertions, green.
  • PHPStan level 4 clean over tests/extensions/Queue, app/init/registers.php, app/worker.php.

The major adds rightPopMany() and incrementBy() to Connection, which is
the whole of its breaking surface here: InMemoryConnection is the only
implementation in this repository, and WorkerConcurrencyTest drives it.
Consumer is unchanged, so FakeConsumer in InitJobsTest needs nothing.

3.0 brings PermanentFailure (a handler can end a message's life rather
than spend its whole redelivery budget on work that cannot succeed), a
pluggable envelope codec, and batched receive -- none of which this
commit takes up. It moves the floor so applications built on server-ce
can.

The lock is not updated yet: utopia-php/platform 1.0.0-rc20 caps queue
at ^2.0.0, so this needs rc21 (utopia-php/monorepo#301) first.
platform rc20 caps queue at ^2.0.0, so the major could not resolve
through it. rc21 widens that and passes a job spec's batch size through
to Server::job(), which is what makes batched receive reachable from an
application at all.
@levivannoort levivannoort self-assigned this Sep 18, 2026
@greptile-apps

greptile-apps Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge; no outstanding correctness, security, or repository-rule violations remain.

Summary

This PR upgrades utopia-php/queue to 3.0 and updates utopia-php/platform to a compatible release candidate.

  • Implements the newly required in-memory connection methods for batched pops and counter increments.
  • Adds worker-level coverage showing that batched processing preserves message delivery and per-queue concurrency isolation.
  • Keeps the Composer manifest and lockfile aligned with the upgraded dependencies.

Reviews (4) · Last reviewed commit: "Merge branch 'main' into feat/queue-3"

@github-actions

github-actions Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → feat/queue-3 (after).

Metric Before After Change
🚀 Requests/sec 482.93 467.46 ⚪ -3.2%
⏱️ Latency P50 35.79 ms 37.01 ms ⚪ +3.4%
⏱️ Latency P95 84.79 ms 87.63 ms ⚪ +3.3%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 37.01 87.63 28,614 467.46 +2.83
Account 65.7 126.7 1,506 25.07 +4.62
TablesDB 35.23 69.33 15,562 256.09 +3.42
Storage 34.58 84.08 7,530 125.87 +3.4
Functions 53.12 104.9 4,016 67.77 +1.96

Top API waits (after)

API request Max wait (ms)
account.name.update 271.38
storage.files.preview 265.12
functions.variables.create 252.48
functions.delete 239.83
functions.create 215.59

Review flagged rightPopMany() for ignoring $timeout. It does, as every
pop in this fake does -- nothing here blocks, an empty pop yields, and
that is what keeps a busy receive loop from starving the handlers it
shares a thread with. Making one method block would be a new behaviour,
not a fix.

The real defect underneath was quieter: each message after the first went
back through pop(), so a batch shorter than asked ended on a yield the
real connection never takes. LMPOP waits for the first message only and
takes the company it finds. The rest now comes straight off the list.

A batch the fake cannot serve looks exactly like an idle queue, so the
failure it would cause is silence. The test claims a three-message
backlog in one receive and asserts the order and the drained queue --
seen red against a rightPopMany() that returns nothing.
The previous test's subject was the fake itself -- it drove
receiveBatch() directly and asserted the broker's return. Review called
that implementation-coupled and it is: a test whose subject is a fixture
proves the fixture, not the worker.

What matters about batching here is the boundary between queues. Batching
changes how many messages one receive claims, not how many run at once,
so the way it could go wrong is by occupying slots another queue is
serialised by, or by losing or duplicating what it claimed. The combined
-mode case now runs its parallel sibling batched and asserts what came
out: every message once, databases still serial, the cap still the cap.

Worth knowing what this cannot see: a batch size that is ignored outright
behaves identically at this boundary, because the whole point of a batch
is fewer round trips and nothing else. Claiming is not observable from
out here.
@levivannoort
levivannoort merged commit f61009b into main Sep 18, 2026
51 of 53 checks passed
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.

2 participants