[13.x] Reconnect after losing the connection during a transaction

Merged
XU
8d ago
+32-0

When the connection is lost inside a transaction, the rollback fails and the level is reset, but the dead PDO is kept. It still thinks it's in a transaction, so every following transaction fails instead of reconnecting:

DB::transaction(function () {
    // connection is lost here
});

DB::transaction(fn () => ...);

// PDOException: There is already an active transaction

A queue worker or Octane process stays broken until it's restarted.