Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysqlctl does not find mysql_install_db in generic tarballs #4975

Closed
morgo opened this issue Jul 2, 2019 · 1 comment · Fixed by #4982
Closed

mysqlctl does not find mysql_install_db in generic tarballs #4975

morgo opened this issue Jul 2, 2019 · 1 comment · Fixed by #4982

Comments

@morgo
Copy link
Contributor

morgo commented Jul 2, 2019

Overview of the Issue

In a generic tarball, mysql_install_db will be located in the scripts/ directory:

morgo@ryzen:~/Downloads$ tar --gzip --list --verbose --file=mysql-5.6.44-linux-glibc2.12-x86_64.tar.gz  | grep mysql_install_db
-rw-r--r-- pb2user/common   14339 2019-03-15 01:55 mysql-5.6.44-linux-glibc2.12-x86_64/man/man1/mysql_install_db.1
-rwxr-xr-x pb2user/common   34558 2019-03-15 09:37 mysql-5.6.44-linux-glibc2.12-x86_64/scripts/mysql_install_db

In ./go/vt/mysqlctl/mysqld.go the binary is searched for with binaryPath:

  cmdPath, err := binaryPath(mysqlRoot, "mysql_install_db")
  if err != nil {
    return err
  }
  if _, _, err = execCmd(cmdPath, args, nil, mysqlRoot, nil); err != nil {
    log.Errorf("mysql_install_db failed: %v", err)
    return err
  }

This function lists a set of subdirs to search, of which scripts should be included:

// binaryPath does a limited path lookup for a command,
// searching only within sbin and bin in the given root.
func binaryPath(root, binary string) (string, error) {
  subdirs := []string{"sbin", "bin", "libexec"}
  for _, subdir := range subdirs {
    binPath := path.Join(root, subdir, binary)
    if _, err := os.Stat(binPath); err == nil {
      return binPath, nil
    }
  }
  return "", fmt.Errorf("%s not found in any of %s/{%s}",
    binary, root, strings.Join(subdirs, ","))
}

Reproduction Steps

Steps to reproduce this issue, example:

source ./dev.env

pgrep -f -l '(vtdataroot|VTDATAROOT)' # list Vitess processes
pkill -f '(vtdataroot|VTDATAROOT)' # kill Vitess processes

sleep 1

for process in `pgrep -f '(vtdataroot|VTDATAROOT)'`; do
 kill -9 $process
done;

export VT_MYSQL_ROOT=/usr/local/mysql
export VTDATAROOT=/tmp/vtdataroot
rm -rf /tmp/vtdataroot

cd examples/local/
./101_initial_cluster.sh

Errors with:

Starting MySQL for tablet zone1-0000000102...
E0702 11:48:24.391879   22619 mysqlctl.go:254] failed init mysql: mysql_install_db not found in any of /usr/local/mysql/{sbin,bin,libexec}
E0702 11:48:24.392027   22618 mysqlctl.go:254] failed init mysql: mysql_install_db not found in any of /usr/local/mysql/{sbin,bin,libexec}
E0702 11:48:24.392044   22620 mysqlctl.go:254] failed init mysql: mysql_install_db not found in any of /usr/local/mysql/{sbin,bin,libexec}

It's an easy fix:

morgo@ryzen:~/go/src/github.com/vitessio/src/vitess.io/vitess$ git diff ./go/vt/mysqlctl/mysqld.go
diff --git a/go/vt/mysqlctl/mysqld.go b/go/vt/mysqlctl/mysqld.go
index 029586d1c..c4f9e5380 100644
--- a/go/vt/mysqlctl/mysqld.go
+++ b/go/vt/mysqlctl/mysqld.go
@@ -453,7 +453,7 @@ func execCmd(name string, args, env []string, dir string, input io.Reader) (cmd
 // binaryPath does a limited path lookup for a command,
 // searching only within sbin and bin in the given root.
 func binaryPath(root, binary string) (string, error) {
-       subdirs := []string{"sbin", "bin", "libexec"}
+       subdirs := []string{"sbin", "bin", "libexec", "scripts"}
        for _, subdir := range subdirs {
                binPath := path.Join(root, subdir, binary)
                if _, err := os.Stat(binPath); err == nil {

Version

Built from master.

morgo added a commit to planetscale/vitess that referenced this issue Jul 9, 2019
Fixes vitessio#4975

Signed-off-by: Morgan Tocker <tocker@gmail.com>
@morgo
Copy link
Contributor Author

morgo commented Jul 11, 2019

I discovered today this patch is also required for generic mariadb tarballs:

morgo@ryzen:~/Downloads$ tar --gzip --list --verbose --file=mariadb-10.0.38-linux-systemd-x86_64.tar.gz | grep mysql_install_db
-rw-r--r-- dbart/my       8488 2019-01-29 11:39 mariadb-10.0.38-linux-systemd-x86_64/man/man1/mysql_install_db.1
-rwxr-xr-x dbart/my      17025 2019-01-29 12:27 mariadb-10.0.38-linux-systemd-x86_64/scripts/mysql_install_db
morgo@ryzen:~/Downloads$ tar --gzip --list --verbose --file=mariadb-10.1.40-linux-systemd-x86_64.tar.gz | grep mysql_install_db
-rw-r--r-- dbart/my       8800 2019-05-07 14:49 mariadb-10.1.40-linux-systemd-x86_64/man/man1/mysql_install_db.1
-rwxr-xr-x dbart/my      19383 2019-05-07 15:38 mariadb-10.1.40-linux-systemd-x86_64/scripts/mysql_install_db
morgo@ryzen:~/Downloads$ tar --gzip --list --verbose --file=mariadb-10.2.25-linux-systemd-x86_64.tar.gz | grep mysql_install_db
-rw-r--r-- dbart/my       8800 2019-06-14 12:29 mariadb-10.2.25-linux-systemd-x86_64/man/man1/mysql_install_db.1
-rwxr-xr-x dbart/my      19257 2019-06-14 15:27 mariadb-10.2.25-linux-systemd-x86_64/scripts/mysql_install_db
morgo@ryzen:~/Downloads$ tar --gzip --list --verbose --file=mariadb-10.3.16-linux-x86_64.tar.gz | grep mysql_install_db
-rwxr-xr-x dbart/my      19458 2019-06-14 16:59 mariadb-10.3.16-linux-x86_64/scripts/mysql_install_db
-rw-r--r-- dbart/my       8800 2019-06-14 16:25 mariadb-10.3.16-linux-x86_64/man/man1/mysql_install_db.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant