#111010Doctrine messenger transport fails with "MySQL server has gone away" in long-running processes
Description
The Doctrine messenger transport gets its own DBAL connection from DoctrineTransportFactory via DriverManager::getConnection(). That connection is not part of the ConnectionPool. It lives as long as the PHP process.
In long-running processes the connection can stay idle longer than the database server allows, for example MySQL’s wait_timeout. The server then closes it. A typical case is scheduler:run executing several tasks in one process: an early task dispatches a message, a later long-running task does not, and a third task dispatches again. The next dispatch() then fails:
An exception occurred in the driver: MySQL server has gone away in vendor/symfony/doctrine-messenger/Transport/DoctrineSender.php:48
Other queries in the same process still work, because they use ConnectionPool connections.
The middlewares added with #110227 do not cover this case. They only act on ConnectionPool connections and only while a worker consumes messages (ConsumedByWorkerStamp). Sending is not covered.
Steps to reproduce
1. Route any message to the doctrine transport.
2. In one CLI process, dispatch a message, wait longer than wait_timeout (or KILL the transport’s connection), then dispatch again.
3. The second dispatch throws “MySQL server has gone away”.
Expected: The transport reconnects and stores the message.
Actual: A TransportException is thrown, the message is lost, and the scheduler task fails.
Proposed fix: When sending fails with Doctrine\DBAL\Exception\ConnectionLost, close the transport’s DBAL connection and retry the send once.
Reviews 1
Related issues 1
History 23
-
Gerrit Code Review pushed patch set 3 for main to change 96568 status
NewUnder Review <span data-processor="relativetime" data-value="2026-10-10T09:59:29+00:00" > 10/10/26, 09:59 </span> -
Georg Ringer changed Related to #111029 <span data-processor="relativetime" data-value="2026-10-12T19:29:32+00:00" > 10/12/26, 19:29 </span>
-
Benni Mack changed status
Under ReviewClosed <span data-processor="relativetime" data-value="2026-10-20T15:30:48+00:00" > 10/20/26, 15:30 </span>