Large amount of entity revision cleaning leads to connection abortion I am trying to remove revisions from each entity type which has the revision feature via drush command.
The amount of entities are quite a lot: around 10K nodes, 2k paragraphs. 

On localhost everything is fine. 
But in the cloud the drush_print($log) successfully runs and the following error appears: 

 [warning] PDO::beginTransaction(): MySQL server has gone away Connection.php:1165
 [warning] PDO::beginTransaction(): Error reading result set's header Connection.php:1165

In Connection.php line 1165:

  SQLSTATE[HY000]: General error: 2006 MySQL server has gone away


The two environments are close to identical. Any suggestions where could I start to investigate?
It turned out what the real issue was. I didn't mention (thought it's not important) that this was actually a Drush command pointing to another multi site. 

The actions took "too long" on the other site and by the time it returned with success, the default Mysql connection was timed out and couldn't write to the database anymore. (even tho the corresponding Mysql timeout settings were way higher than the actual amount of time that was spent on the other site)

We solved with with 

$process = proc_open($command, [STDIN, STDOUT, STDERR], $pipes);
if (!is_resource($process)) {
  throw new \InvalidArgumentException("Could not execute `{$command}`.");
}
while (($status = proc_get_status($process)) &amp;&amp; ($status['running'])) {
  $this-&gt;entityStorage-&gt;getQuery()-&gt;count()-&gt;execute();
  sleep(5);
}
proc_close($process);