dpkg: percona-server-server-5.7.postinst fail to find the right MYSQLDATA

Bug #1705729 reported by Maxime de Roucy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona Server moved to https://jira.percona.com/projects/PS
Status tracked in 5.7
5.5
Fix Released
High
EvgeniyPatlan
5.6
Fix Released
High
EvgeniyPatlan
5.7
Fix Released
High
EvgeniyPatlan

Bug Description

On debian jessie, I have :

root@test:~# grep -v '^#' /etc/mysql/my.cnf
!includedir /etc/mysql/percona-server.conf.d/
!includedir /etc/mysql/conf.d/
root@test:~# grep datadir /etc/mysql/percona-server.conf.d/*
/etc/mysql/percona-server.conf.d/mysqld.cnf:datadir = /var/lib/mysql
root@test:~# grep datadir /etc/mysql/conf.d/*
datadir = /space/mysql

so the right datadir is /space/mysql.

From https://dev.mysql.com/doc/refman/5.7/en/option-files.html :

  If multiple instances of a given option are found, the last instance takes precedence, with one
  exception: For mysqld, the first instance of the --user option is used as a security precaution, to
  prevent a user specified in an option file from being overridden on the command line.

In /var/lib/dpkg/info/percona-server-server-5.7.postinst :

  MYSQLDATA=$(my_print_defaults mysqld | grep datadir | cut -d= -f2)

root@test:~# my_print_defaults mysqld | grep datadir | cut -d= -f2
/var/lib/mysql
/space/mysql

In /var/lib/dpkg/info/percona-server-server-5.7.postinst to determine if the datadir is empty :

  [ ! "$(ls -A ${MYSQLDATA})" ]

but :

root@test:~# ls -A /space/mysql
root@test:~# ls -A /var/lib/mysql /space/mysql
/space/mysql:

/var/lib/mysql:

So the test fail even if the datadir is empty.

What I propose :

  MYSQLDATA=$(my_print_defaults mysqld | grep -- '--datadir=' | tail -n 1 | cut -d= -f2)

root@test:~# my_print_defaults mysqld | grep -- '--datadir=' | tail -n 1 | cut -d= -f2
/space/mysql

--
Regards

Tags: pkg
Revision history for this message
Maxime de Roucy (mderoucy) wrote :

root@test:~# cat /etc/apt/sources.list.d/percona.list
deb http://repo.percona.com/apt jessie main

root@test:~# dpkg -l percona-server-server-5.7
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-===============================================-============================-============================-===================================================================================================
ii percona-server-server-5.7 5.7.18-15-1.jessie amd64 Percona Server database server binaries

Revision history for this message
EvgeniyPatlan (evgeniy-patlan) wrote : Re: [Bug 1705729] Re: dpkg: percona-server-server-5.7.postinst fail to find the right MYSQLDATA
Download full text (3.7 KiB)

in your case datadir should be taken
from /etc/mysql/percona-server.conf.d/mysqld.cnf and it is default config
file.

On Fri, Jul 21, 2017 at 6:45 PM, Maxime de Roucy <<email address hidden>
> wrote:

> root@test:~# cat /etc/apt/sources.list.d/percona.list
> deb http://repo.percona.com/apt jessie main
>
> root@test:~# dpkg -l percona-server-server-5.7
> Desired=Unknown/Install/Remove/Purge/Hold
> | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/
> trig-aWait/Trig-pend
> |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
> ||/ Name Version
> Architecture Description
> +++-===============================================-========
> ====================-============================-==========
> ============================================================
> =============================
> ii percona-server-server-5.7 5.7.18-15-1.jessie
> amd64 Percona Server database server binaries
>
> --
> You received this bug notification because you are a member of Percona
> core, which is subscribed to Percona Server.
> https://bugs.launchpad.net/bugs/1705729
>
> Title:
> dpkg: percona-server-server-5.7.postinst fail to find the right
> MYSQLDATA
>
> Status in Percona Server:
> New
>
> Bug description:
> On debian jessie, I have :
>
> root@test:~# grep -v '^#' /etc/mysql/my.cnf
> !includedir /etc/mysql/percona-server.conf.d/
> !includedir /etc/mysql/conf.d/
> root@test:~# grep datadir /etc/mysql/percona-server.conf.d/*
> /etc/mysql/percona-server.conf.d/mysqld.cnf:datadir = /var/lib/mysql
> root@test:~# grep datadir /etc/mysql/conf.d/*
> datadir = /space/mysql
>
> so the right datadir is /space/mysql.
>
> From https://dev.mysql.com/doc/refman/5.7/en/option-files.html :
>
> If multiple instances of a given option are found, the last instance
> takes precedence, with one
> exception: For mysqld, the first instance of the --user option is used
> as a security precaution, to
> prevent a user specified in an option file from being overridden on
> the command line.
>
> In /var/lib/dpkg/info/percona-server-server-5.7.postinst :
>
> MYSQLDATA=$(my_print_defaults mysqld | grep datadir | cut -d= -f2)
>
> root@test:~# my_print_defaults mysqld | grep datadir | cut -d= -f2
> /var/lib/mysql
> /space/mysql
>
> In /var/lib/dpkg/info/percona-server-server-5.7.postinst to determine
> if the datadir is empty :
>
> [ ! "$(ls -A ${MYSQLDATA})" ]
>
> but :
>
> root@test:~# ls -A /space/mysql
> root@test:~# ls -A /var/lib/mysql /space/mysql
> /space/mysql:
>
> /var/lib/mysql:
>
> So the test fail even if the datadir is empty.
>
> What I propose :
>
> MYSQLDATA=$(my_print_defaults mysqld | grep -- '--datadir=' | tail
> -n 1 | cut -d= -f2)
>
> root@test:~# my_print_defaults mysqld | grep -- '--datadir=' | tail -n
> 1 | cut -d= -f2
> /space/mysql
>
> --
> Regards
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/percona-server/+bug/1705729/+subscriptions
>
> Launchpad-Notification-Type: bug
> Launchpad-Bug: product=percona-ser...

Read more...

Revision history for this message
Maxime de Roucy (mderoucy) wrote :

@evgeniy-patlan I don't really understand what you mean…
datadir should be extracted as mysqld does, so it should be taken from /etc/my.cnf, /etc/mysql/my.cnf and SYSCONFDIR/my.cnf (cf. https://dev.mysql.com/doc/refman/5.7/en/option-files.html) which are the global config files.

This command does that :

  my_print_defaults mysqld

But the rest of the script fail because it doesn't take into account this sentence from the mysql documentation :

  If multiple instances of a given option are found, the last instance takes precedence, with one
  exception: For mysqld, the first instance of the --user option is used as a security precaution,
  to prevent a user specified in an option file from being overridden on the command line.

If the datadir used by the script should be the default one (as you seems to say) why bothering retrieving it from the configuration ? Just use /var/lib/mysql ; as it is the default datadir.

Can you elaborate ?

Regards

Changed in percona-server:
assignee: nobody → Sveta Smirnova (svetasmirnova)
Revision history for this message
Sveta Smirnova (svetasmirnova) wrote :

Thank you for the report.

Verified as described.

Changed in percona-server:
status: New → Confirmed
Revision history for this message
Sveta Smirnova (svetasmirnova) wrote :

Versions 5.5 and 5.6 just ignores datadir, specified in the latest configuration file (installs everything into /var/lib/mysql) and 5.7 fails with error.

Revision history for this message
EvgeniyPatlan (evgeniy-patlan) wrote :
Revision history for this message
EvgeniyPatlan (evgeniy-patlan) wrote :
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-1111

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.