laravel/framework · error · Exception
Dump execution exceeded maximum depth of 30.
Error message
Dump execution exceeded maximum depth of 30.
What it means
MySqlSchemaState.executeDumpProcess() recurses to retry mysqldump after stripping incompatible flags (--column-statistics, --set-gtid-purged). A hard depth cap of 30 prevents infinite recursion if each retry keeps failing in a way that matches the retry patterns. Hitting it means the dump repeatedly failed-and-retried 30 times.
Source
Thrown at src/Illuminate/Database/Schema/MySqlSchemaState.php:182
'LARAVEL_LOAD_SSL_KEY' => $config['options'][Mysql::ATTR_SSL_KEY] ?? '',
];
}
/**
* Execute the given dump process.
*
* @param \Symfony\Component\Process\Process $process
* @param callable $output
* @param array $variables
* @param int $depth
* @return \Symfony\Component\Process\Process
*
* @throws \Throwable
*/
protected function executeDumpProcess(Process $process, $output, array $variables, int $depth = 0)
{
if ($depth > 30) {
throw new Exception('Dump execution exceeded maximum depth of 30.');
}
try {
$process->setTimeout(null)->mustRun($output, $variables);
} catch (Exception $e) {
if (Str::contains($e->getMessage(), ['column-statistics', 'column_statistics'])) {
return $this->executeDumpProcess(Process::fromShellCommandLine(
str_replace(' --column-statistics=0', '', $process->getCommandLine())
), $output, $variables, $depth + 1);
}
if (str_contains($e->getMessage(), 'set-gtid-purged')) {
return $this->executeDumpProcess(Process::fromShellCommandLine(
str_replace(' --set-gtid-purged=OFF', '', $process->getCommandLine())
), $output, $variables, $depth + 1);
}
throw $e;View on GitHub (pinned to bd6b5437e6)
Solutions
- Inspect the actual mysqldump error by running the dump command manually — the depth cap masks the root cause.
- Align the mysql-client version with the server version (e.g. pin mysql-client in your Docker/CI image).
- If using MariaDB, ensure the schema state class is the MariaDbSchemaState (use a MariaDB driver), not MySQL's.
- Upgrade or downgrade mysqldump until --column-statistics / --set-gtid-purged are natively handled.
Example fix
// before — schema:dump loops on version-skewed mysqldump
Artisan::call('schema:dump');
// after — run the failing dump by hand to read the real error
// $ mysqldump -u root -p db --column-statistics=0 > out.sql
// then pin the matching client in CI, e.g. compose.yml:
// services:
// mysql:
// image: mysql:8.0
// artisan:
// image: yourapp:php
// depends_on: [mysql]
// # install mysql-client 8.0 to match the server Defensive patterns
Strategy: try-catch
Validate before calling
// No programmatic pre-check; surface real mysqldump error instead. // Run the dump command manually first: // $ mysqldump -u $DB_USER -p$DB_PASS $DB_DB --column-statistics=0 > /tmp/probe.sql
Try / catch
try {
Artisan::call('schema:dump');
} catch (\Exception $e) {
if (str_contains($e->getMessage(), 'maximum depth of 30')) {
// run mysqldump manually to read the real error; align client/server versions
throw new \RuntimeException('schema:dump looped; run mysqldump manually to diagnose', 0, $e);
}
throw $e;
} Prevention
- Pin the mysql-client version to match the server in CI and Docker images.
- Use MariaDbSchemaState for MariaDB, not the MySQL one.
- Run mysqldump manually whenever schema:dump behaves oddly to read the underlying error.
When it happens
Trigger: Running schema:dump (or the test harness that calls it) where mysqldump keeps failing on --column-statistics or --set-gtid-purged and the error message still contains those substrings after the flag is stripped — e.g. a mysqldump version mismatch where the error text mentions the flag but stripping it does not resolve the underlying failure. Each recursive call increments depth until 30 is exceeded.
Common situations: mysqldump client/server version skew (8.0 client vs older server); MariaDB vs MySQL flag differences; corrupted installation where the flag-stripping heuristic loops; CI images with mismatched mysql-client versions.
Related errors
- This database driver requires a type, see the virtualAs / st
- Schema dumping is not supported when using SQL Server.
- The chunkById operation was aborted because the [{$alias}] c
- The chunk size should be at least 1
- The lazyById operation was aborted because the [{$alias}] co
AI-assisted analysis of laravel/framework@bd6b5437e6 (2026-08-06).
Data as JSON: /data/errors/343f1320333959a1.json.
Report an issue: GitHub.