Page MenuHomePhabricator

"sql" command fails with "sh: 1: mysql: not found" on mwdebug1002
Closed, ResolvedPublic


I'm not sure if this command used to work before but either it should work, or not be provisioned on the server in question.

Event Timeline

I don't know if it used to work on the old hosts.
MySQL client isn't installed there - not sure if it used to be and "got lost" when migrating to stretch.

The "sql" command works on maintenance servers, so mwmaint1002. At first i thought it was about them and the switch from terbium -> mwmaint1002 but this is an mwdebug host so like a regular app server.

Do you have a preference which way around this should be solved? Do you need it on debug hosts and not just maintenance hosts?

The "sql" command itself is installed from the scap module within puppet in scap::scripts. fwiw, existing FIXME comments there include "# FIXME: Why isn't this in a package?"

"sql" translates to "exec mwscript mysql.php" and that translates to "php /srv/mediawiki/multiversion/MWScript.php mysql.php --wiki=metawiki --wikidb=enwiki"

looking at mysq.php there is

 37         $this->addDescription( "Execute the MySQL client binary. " .
 38             "Non-option arguments will be passed through to mysql." );

151         $args = [
152             'mysql',

bash: mysql: command not found obviously on mwdebug1002 as reported.

on mwmaint1002 we have it but it comes from /usr/local/bin/ so not from a package.

role::mediawiki_maintenance includes profile::mariadb::client which uses class { 'mariadb::packages_client':

That installs "'wmf-mariadb101-client', # mariadb client, custom wmf package" which exclusively installs packages into /opt/.

There are symlinks from /usr/local/bin/mysql to /etc/alternatives/mysql to /opt/wmf-mariadb101-client/bin/mysql.

A role::mediawiki::canary_appserver server like mwdebug includes scap::scripts but does not include a ::profile::mariadb::client resulting in this.

Change 479142 had a related patch set uploaded (by Dzahn; owner: Dzahn):
[operations/puppet@production] mediawiki/scap: do not install sql scripts on canary appservers

Dzahn triaged this task as Medium priority.Dec 11 2018, 11:12 PM

I don't have a preference for whether to remove or keep the sql command on mwdebug/canary servers. However, looking at the above patch, I notice something else:

class role::mediawiki::canary_appserver {
    include role::mediawiki::appserver
    include ::profile::base::firewall
    # include the deployment scripts because mwscript can occasionally be useful
    # here: T112174
    include scap::scripts

I think it makes sense for the sql and mwscript commands to come together. That is, either we can stage changes for maintenance scripts and run them on mwdebug hosts, or we can't. If we decide that we shouldn't do so, the alternative would be to run those from the deployment host instead, which afaik have all the provisioning that maintenance hosts have. Is that correct?

If so, I'd suggest we remove both, and not absent just one of its commands. I think that would increase confusion. However, I don't mind if we do that first, because it's clearly not working currently, so we might as well remove it.

However, what I'm actually wondering now is... why isn't the mysql command part of scap::scripts? Perhaps adding it to that would make more sense. (and then deciding to keep or remove that on canary servers) It would certainly keep things simpler for developers to understand in terms of CLI user experience.

This has been brought this up in our meeting today by @jijiki what do you think of in light of the comments from meeting?

Change 479142 merged by Dzahn:
[operations/puppet@production] mediawiki/scap: do not install sql scripts on canary appservers

Dzahn claimed this task.

@Krinkle The change above has been merged today. This removed the non-working sql / sqldump scripts from canary appservers, including mwdebug1002.

Notice: /Stage[main]/Scap::Scripts/File[/usr/local/bin/sql]/ensure: removed

Notice: /Stage[main]/Scap::Scripts/File[/usr/local/bin/sqldump]/ensure: removed

[mwdebug1002:~] $ sql
-bash: sql: command not found