acquia / acsf-tools

Command line tools for working with Acquia Cloud Site Factory
21 stars 25 forks source link

mysql dump failing with PROCESS privilege permissions failure #127

Open alex-moreno opened 3 years ago

alex-moreno commented 3 years ago

See: https://github.com/drush-ops/drush/issues/4489

> mysqldump: Error: 'Access denied; you need (at least one of) the PROCESS privilege(s) for this operation' when trying to dump tablespaces

Other projects seem to fix it in a similar way (just adding the flag): https://github.com/massgov/openmass/pull/646/files

Cloud IDE has solved it in a different way, granting permissions, but that may not be suitable for everyone as per security concerns: https://github.com/acquia/ads-remote-ide-proxy/pull/381/files

More information:

vbouchet31 commented 3 years ago

As per the code of acsf-tools-dump, it looks like it is passing all the options to sql-dump

// Get options passed to this drush command & append it with options
// needed by the next command to execute.
$options = Drush::redispatchOptions();
unset($options['php']);
unset($options['php-options']);
unset($options['result-folder']);

$options['result-file'] = $backup_result_folder . '/' . $details['machine_name'] . '.sql';
$options['uri'] = $domain;

$this->output()->writeln("=> Taking database dump of {$details['machine_name']} ...");
$self = $this->siteAliasManager()->getSelf();
// Remove empty values from array.
$options = array_filter($options);
$process = Drush::drush($self, $command, $arguments, $options);

I think executing drush acsf-tools-dump --result-folder=/tmp --no-tablespaces --gzip should work.

If that is the case, we should probably remove the explicit mention to --gzip and instead mention that all options except --result-folder (--result-file which is dynamically calculated) are given to the drush sql-dump command.

andrii-aleksandrov-smile commented 3 years ago

@vbouchet31 Probably you are right, but this option should be allowed in the command annotation first.

   * @command acsf-tools:dump
   *
   * @bootstrap site
   * @param array $options An associative array of options whose values come from cli, aliases, config, etc.
   * @option result-folder
   *   The folder in which the dumps will be written. Defaults to ~/drush-backups.
   * @option gzip
   *   Compress the dump into a zip file.
   *
vbouchet31 commented 3 years ago

Hi @andrii-aleksandrov-smile

I think it is a "recent" change with drush. On previous (not sure which previous ;-) ), drush was accepting arbitrary options. Now I suspect it is either breaking or stripping unknown options.

My suggestion instead of allowing explicit options (--no-tablespaces for example) would be to add a specific option for which the values would be passed to sql-dump command.

drush acsf-tools-dump --sql-dump-extra="--extra=--no-tablespaces --another-option"

I won't have time to work on this soon but if you feel the suggestion is the proper approach, patch is welcome.

cc @sdelbosc (for the approach) cc @tguilpain