drush
drush copied to clipboard
drush sql:cli fails with "write(): Write of 4096 bytes failed with errno=32 Broken pipe" error if collation data is invalid
I received a sql
dump file from a colleague that was generated with drush sql:dump
. However, the collation data was incorrect. On Drush version 11.3.2 (EDIT: also appear to occur with latest 11.5.1) and MariaDB 10.4.28, I got errors like these:
</pre><em class="placeholder">Notice</em>: fwrite(): Write of 4096 bytes failed with errno=32 Broken pipe in <em class="placeholder">Symfony\Component\Process\Pipes\AbstractPipes->write()</em> (line <em class="placeholder">130</em> of <em class="placeholder">/var/www/html/vendor/symfony/process/Pipes/AbstractPipes.php</em>). <pre class="backtrace">Symfony\Component\Process\Pipes\AbstractPipes->write() (Line: 108)
Symfony\Component\Process\Pipes\UnixPipes->readAndWrite(1, 1) (Line: 1435)
Symfony\Component\Process\Process->readPipes(1, 1) (Line: 432)
Symfony\Component\Process\Process->wait() (Line: 251)
Symfony\Component\Process\Process->run(Object, Array) (Line: 268)
Symfony\Component\Process\Process->mustRun(Object) (Line: 151)
Drush\Commands\sql\SqlCommands->cli(Object, Array)
call_user_func_array(Array, Array) (Line: 257)
Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object) (Line: 212)
Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object) (Line: 176)
Consolidation\AnnotatedCommand\CommandProcessor->process(Object, Array, Array, Object) (Line: 390)
Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object, Object) (Line: 255)
Symfony\Component\Console\Command\Command->run(Object, Object) (Line: 1039)
Symfony\Component\Console\Application->doRunCommand(Object, Object, Object) (Line: 275)
Symfony\Component\Console\Application->doRun(Object, Object) (Line: 149)
Symfony\Component\Console\Application->run(Object, Object) (Line: 124)
Drush\Runtime\Runtime->doRun(Array, Object) (Line: 51)
Drush\Runtime\Runtime->run(Array) (Line: 77)
require('/var/www/html/vendor/drush/drush/drush.php') (Line: 4)
include('/var/www/html/vendor/drush/drush/drush') (Line: 120)
No data was being imported. In my case, I needed to update these collation data:
-
sed -i 's/utf8mb4_0900_ai_ci/utf8mb4_general_ci/g' dump.sql
-
sed -i 's/CHARSET=utf8mb4mb3/CHARSET=utf8mb4/g' dump.sql
(From https://tecadmin.net/resolved-unknown-collation-utf8mb4_0900_ai_ci/)
The first line already solved the issue, causing Drush to process the file until it encountered the unknown utf8mb4mb3
character set.
This might be an issue that has to be fixed upstream in Symfony, but I couldn't find anything pertaining to this. Perhaps we can catch the error and inform the user?