drush icon indicating copy to clipboard operation
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

Open beerendlauwers opened this issue 1 year ago • 0 comments

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-&gt;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-&gt;write() (Line: 108)
Symfony\Component\Process\Pipes\UnixPipes-&gt;readAndWrite(1, 1) (Line: 1435)
Symfony\Component\Process\Process-&gt;readPipes(1, 1) (Line: 432)
Symfony\Component\Process\Process-&gt;wait() (Line: 251)
Symfony\Component\Process\Process-&gt;run(Object, Array) (Line: 268)
Symfony\Component\Process\Process-&gt;mustRun(Object) (Line: 151)
Drush\Commands\sql\SqlCommands-&gt;cli(Object, Array)
call_user_func_array(Array, Array) (Line: 257)
Consolidation\AnnotatedCommand\CommandProcessor-&gt;runCommandCallback(Array, Object) (Line: 212)
Consolidation\AnnotatedCommand\CommandProcessor-&gt;validateRunAndAlter(Array, Array, Object) (Line: 176)
Consolidation\AnnotatedCommand\CommandProcessor-&gt;process(Object, Array, Array, Object) (Line: 390)
Consolidation\AnnotatedCommand\AnnotatedCommand-&gt;execute(Object, Object) (Line: 255)
Symfony\Component\Console\Command\Command-&gt;run(Object, Object) (Line: 1039)
Symfony\Component\Console\Application-&gt;doRunCommand(Object, Object, Object) (Line: 275)
Symfony\Component\Console\Application-&gt;doRun(Object, Object) (Line: 149)
Symfony\Component\Console\Application-&gt;run(Object, Object) (Line: 124)
Drush\Runtime\Runtime-&gt;doRun(Array, Object) (Line: 51)
Drush\Runtime\Runtime-&gt;run(Array) (Line: 77)
require(&#039;/var/www/html/vendor/drush/drush/drush.php&#039;) (Line: 4)
include(&#039;/var/www/html/vendor/drush/drush/drush&#039;) (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?

beerendlauwers avatar Apr 24 '23 12:04 beerendlauwers