mysql_install_db not handling mysqld startup failure

Bug #1382782 reported by Vlad Lesin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MySQL Server
Unknown
Unknown
Percona Server moved to https://jira.percona.com/projects/PS
Fix Released
Medium
Vlad Lesin
5.1
Fix Released
Medium
Vlad Lesin
5.5
Fix Released
Medium
Vlad Lesin
5.6
Fix Released
Medium
Vlad Lesin

Bug Description

Consider lp:mysql-server/5.6 revision 6130.

If we look into scripts/mysql_install_db.pl.in lines 753-958 are responsible for invoking mysqld in bootstrap mode and feeding the following files to it:
my $create_system_tables = "$pkgdatadir/mysql_system_tables.sql";
my $fill_system_tables = "$pkgdatadir/mysql_system_tables_data.sql";

The code use 'open(PIPE, "| $mysqld_install_cmd_line")' perl construction which allows easily work with pipes, but the return code of mysqld is not checked, so if something went wrong (for example mutually exclusive mysqld options are used) mysql_install_db will ignore the error and continue the execution.

I would propose to check the return value of perl "close" function when the pipe is closed. Here is the description how to check error code of the child on another side of pipe with "close":

"If the filehandle came from a piped open, close returns false if one of the other syscalls involved fails or if its program exits with non-zero status. If the only problem was that the program exited non-zero, $! will be set to 0 . Closing a pipe also waits for the process executing on the pipe to exit--in case you wish to look at the output of the pipe afterwards--and implicitly puts the exit status value of that command into $? and ${^CHILD_ERROR_NATIVE}." (http://perldoc.perl.org/functions/close.html)

In the case of unexpected mysqld termination mysql_install_db must be stopped with corresponding error message.

How to repeate:

Run mysql_install_db in 5.6 with --enforce-gtid-consistency=1 --autocommit=0 options. The server terminates with the following error message:

ERROR: 1787 When @@GLOBAL.ENFORCE_GTID_CONSISTENCY = 1, the statements CREATE TEMPORARY TABLE and DROP TEMPORARY TABLE can be executed in a non-transactional context only, and require that AUTOCOMMIT = 1.

But mysql_install_db continues execution. As a result system tables will not be created and filled in.

Tags: upstream
Vlad Lesin (vlad-lesin)
description: updated
Vlad Lesin (vlad-lesin)
description: updated
tags: added: upstream
Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PS-1553

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.