facile-it/doctrine-mysql-come-back
A Doctrine DBAL extension that automatically reconnects to MySQL after connection loss and retries failed queries, helping long-running Laravel/PHP apps and workers recover from dropped database connections without manual reconnection handling.
Architecture fit: The package is a narrow resilience wrapper for Doctrine DBAL connections, specifically targeting MySQL “server has gone away” conditions. It fits Laravel/PHP only when the application already uses Doctrine DBAL—for example through laravel-doctrine/orm, legacy Doctrine modules, or custom DBAL connection factories. It is not a direct fit for standard Laravel Eloquent/PDO usage; Laravel’s DB facade and Eloquent connections are PDO-based, so this package would not be exercised unless the application introduces Doctrine DBAL as an additional data-access layer. Introducing Doctrine solely to gain reconnect behavior is not justified.
Integration feasibility: Feasible as a targeted infrastructure change if the app already owns a Doctrine DBAL connection configuration. The TPM should treat it as a connection-factory concern, not an application-wide dependency. Integration effort is likely low for a Doctrine-based service and high for an Eloquent-first Laravel app because it implies a parallel persistence stack. Verify supported DBAL major versions and PHP versions against the application matrix before committing.
Technical risk: The main risk is semantic, not syntactic. Automatic reconnect/retry can mask chronic MySQL/proxy/network instability and may interact poorly with transactions, savepoints, read/write splitting, connection pooling, and non-idempotent writes. A retried statement after a connection drop can be safe for reads but ambiguous for writes if the server may have processed the original statement. Long-running Laravel Queue workers and Octane processes benefit from stale-connection handling, but retries must be bounded and observable.
Key questions:
Stack fit: Strong fit only for Doctrine DBAL-backed Laravel services; weak fit for standard Laravel Eloquent services. For an Eloquent-first stack, prefer framework-native controls such as connection validation, DB::reconnect() in job middleware, tuned wait_timeout, health checks, and queue worker lifecycle settings rather than adding Doctrine DBAL.
Migration path: If already on Doctrine DBAL, adopt incrementally: pin the package version, replace the connection class/factory in one service or module, run it in staging against the same MySQL/proxy topology, then expand to additional Doctrine connections. Avoid a big-bang replacement across all services. If not on Doctrine, do not migrate persistence layers for this package alone.
Compatibility: Confirm DBAL major version support, PHP version constraints, MySQL variants, and compatibility with any connection pooler or proxy such as ProxySQL or Aurora-style endpoints. Validate behavior under Laravel Octane, queue workers, and long-running CLI processes, since those are the contexts where “gone away” is most relevant.
Sequencing: Start with a discovery gate: inventory Doctrine DBAL usage and current reconnect handling. Then prototype in one low-risk read-heavy workload, add metrics and structured logs for reconnect attempts, run failure-injection tests by killing connections and forcing wait_timeout, and only then promote to write-capable services with strict retry limits. Keep a rollback path to the prior connection factory.
Maintenance: Low code footprint and Apache-2.0 licensing are favorable. However, the repository is unknown in this assessment, stars are modest, and the opportunity score is low, so dependency review should include maintainer activity, issue responsiveness, release cadence, and security advisory history. The recent release date is positive but not sufficient alone.
Support: Expect limited vendor-style support. The team should own configuration, observability, and incident playbooks. Document exactly when reconnect occurs, what is retried, and what is not. Avoid relying on the package as the primary fix for unstable database infrastructure.
Scaling: Useful for long-running PHP workers and occasional stale connections, but not a substitute for connection pooling, database health checks, backoff, or infrastructure remediation. At scale, unbounded reconnect attempts can create retry storms or hide systemic failures. Bound retries, add jitter/backoff where applicable, and alert on reconnect frequency.
Failure modes: Watch for retries after ambiguous writes, lost transaction state, stale prepared statements, duplicate side effects, connection pool exhaustion, and masking of MySQL/proxy outages. Also watch for silent behavior differences between Doctrine DBAL and Laravel’s native PDO path if both are used.
Ramp-up: Low for engineers already familiar with Doctrine DBAL; moderate for Laravel-centric teams who rarely touch Doctrine connection internals. Provide a short runbook: when reconnect is expected, how to read metrics, how to disable the wrapper, and how to distinguish application retry behavior from infrastructure failure.
How can I help you explore Laravel packages today?