From 3e33964bbca3db6be085c003c7d35d87ba3ab400 Mon Sep 17 00:00:00 2001 From: max Date: Wed, 7 Oct 2026 12:38:02 +0300 Subject: [PATCH 1/2] Pgmq: poll again right after a full batch instead of waiting for the next signal A backlog that is already in the queue produces no further insert notifications, so after reading one batch the consumer slept until the poll interval elapsed: a queue of N messages took ~N/batch * pollInterval (5 s by default) to drain. --- src/MessageBus/Pgmq/PgmqTransport.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/MessageBus/Pgmq/PgmqTransport.php b/src/MessageBus/Pgmq/PgmqTransport.php index 66bdca6..d627fb4 100644 --- a/src/MessageBus/Pgmq/PgmqTransport.php +++ b/src/MessageBus/Pgmq/PgmqTransport.php @@ -196,7 +196,7 @@ public function startConsumer(string $queue, ConsumerHandler $handler): PgmqCons $iterator = $polls->iterate(); - EventLoop::queue(function () use ($queue, $handler, $completion, $watcher, $iterator): void { + EventLoop::queue(function () use ($queue, $handler, $completion, $watcher, $iterator, $polls): void { $watcher->watch(); try { @@ -238,6 +238,12 @@ public function startConsumer(string $queue, ConsumerHandler $handler): PgmqCons } finally { EventLoop::cancel($updateVisibilityId); } + + // A full batch means the queue may hold more messages. Inserts that already happened will not + // notify again, so waiting for the next signal would leave the backlog idle for up to $pollInterval. + if (\count($messages) === $this->batchSize && !$polls->isComplete()) { + $polls->pushAsync(null)->ignore(); + } } $completion->complete(); From b09e52a0c39e8d623a37f6d78465f430dc01981e Mon Sep 17 00:00:00 2001 From: max Date: Wed, 7 Oct 2026 12:42:21 +0300 Subject: [PATCH 2/2] Remove the @phpstan-ignore that no longer matches Recent PHPStan 2.2.x infers the nested property assignment correctly, so the ignore is unmatched and phpstan fails on every cell of the CI matrix (8.4/8.5 x lowest/highest). (cherry picked from commit ec4557352169cfe1a978542690ccd9bfbedfba04) --- src/MessageBus/Handling/Handlers.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/MessageBus/Handling/Handlers.php b/src/MessageBus/Handling/Handlers.php index b55ba5f..9aacd48 100644 --- a/src/MessageBus/Handling/Handlers.php +++ b/src/MessageBus/Handling/Handlers.php @@ -54,7 +54,6 @@ public function with(string $messageClass, callable $handler, string $qualifier } $copy = clone $this; - /** @phpstan-ignore assign.propertyType */ $copy->handlers[$messageClass][$qualifier] = $handler; return $copy;