xtrabackup sst fails if tmpdir is specified more than once in my.cnf

Bug #1160047 reported by markus_albe
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MySQL patches by Codership
Fix Released
Undecided
Alex Yurchenko
Percona XtraDB Cluster moved to https://jira.percona.com/projects/PXC
Fix Released
Undecided
Raghavendra D Prabhu

Bug Description

wsrep_sst_xtrabackup will fail with "innobackupex: Too many command line arguments" error if the tmpdir option is specified more than once in my.cnf

A possible solution would be to add "|tail -n1" to this

TMPDIR=$(grep -E '^\s*tmpdir' $WSREP_SST_OPT_CONF | awk -F = '{ print $2 }' | sed 's/^\s//g' | sed 's/\s.*//g' )

So would be

TMPDIR=$(grep -E '^\s*tmpdir' $WSREP_SST_OPT_CONF | awk -F = '{ print $2 }' | sed 's/^\s//g' | sed 's/\s.*//g' |tail -n1)

Still could be that the last tmpdir is not the right one (could be under a different options group other than [mysqld]). I think the following line should work always:

grep -E '^\s*tmpdir' $WSREP_SST_OPT_CONF | awk -F = '{ print $2 }' | sed 's/^\s//g' | sed 's/\s.*//g'

Tags: i30521
Changed in percona-xtradb-cluster:
status: New → Triaged
Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :

I think this entire segment

        TMPDIR=${TMPDIR:-""}
        if [ -z "${TMPDIR}" ]; then
            # try to get it from my.cnf
            TMPDIR=$(grep -E '^\s*tmpdir' $WSREP_SST_OPT_CONF | \
                     awk -F = '{ print $2 }' | sed 's/^\s//g' | sed 's/\s.*//g' )
            # if failed default to /tmp
            [ -z "${TMPDIR}" ] && TMPDIR="/tmp"
        fi

is not required. If a separate tmpdir for xtrabackup is required
(by default it will use mysql's), then it can be passed through
tmpdir variable under [xtrabackup] in my.cnf

Revision history for this message
markus_albe (markus-albe) wrote :

Ooooooops :-\ Seems I pasted the wrong line "that works". Here's the good one:

 mysqld --print-defaults | grep -P -o "\-\-tmpdir=[^\s]+" |awk -F"=" '{ print $2}' | sed 's/^\s//g' | sed 's/\s.*//g'

I agree with tmpdir under [xtrabackup] section idea too.

Revision history for this message
Joseph McHenry (joseph-i) wrote :

The solution offered does not distinguish between separate section headings.

We have a tmpdir setting under section headings, [mysql.server] and [mysqld]. Which one should be applied?

Revision history for this message
markus_albe (markus-albe) wrote : Re: [Bug 1160047] Re: xtrabackup sst fails if tmpdir is specified more than once in my.cnf

Well, this won't parse the my.cnf, it will let mysqld parse the my.cnf
and then use whatever mysqld decided it was good to use.

On 04/03/2013 02:24 PM, Joseph McHenry wrote:
> The solution offered does not distinguish between separate section
> headings.
>
> We have a tmpdir setting under section headings, [mysql.server] and
> [mysqld]. Which one should be applied?
>

Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :

@Joseph,

You need to provide tmpdir under [xtrabackup] heading for
xtrabackup to use a different one.

Changed in percona-xtradb-cluster:
assignee: nobody → Raghavendra D Prabhu (raghavendra-prabhu)
Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :

On a closer examination, it may be that xtrabackup may not be
using tmpdir under [xtrabackup] for xtrabackup_target_dir when it
is streaming.

Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :
Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :

Because of that bug, TMPDIR may be still required for the other parts of that script.

So,

=== modified file 'Percona-Server/scripts/wsrep_sst_xtrabackup.sh'
--- Percona-Server/scripts/wsrep_sst_xtrabackup.sh 2012-12-06 13:26:02 +0000
+++ Percona-Server/scripts/wsrep_sst_xtrabackup.sh 2013-04-08 04:26:06 +0000
@@ -101,13 +101,13 @@
         TMPDIR=${TMPDIR:-""}
         if [ -z "${TMPDIR}" ]; then
             # try to get it from my.cnf
- TMPDIR=$(grep -E '^\s*tmpdir' $WSREP_SST_OPT_CONF | \
- awk -F = '{ print $2 }' | sed 's/^\s//g' | sed 's/\s.*//g' )
+ TMPDIR=$(xtrabackup --print-param \
+ | awk -F"=" '/tmpdir/ { print $2 }' | tr -d '"')
             # if failed default to /tmp
             [ -z "${TMPDIR}" ] && TMPDIR="/tmp"
         fi

- INNOBACKUPEX_ARGS="--galera-info --tmpdir=${TMPDIR} --stream=tar
+ INNOBACKUPEX_ARGS="--galera-info --stream=tar
                            --defaults-file=${WSREP_SST_OPT_CONF}
                            --socket=${WSREP_SST_OPT_SOCKET}"

looks good.

Also, note that, to pass a tmpdir to xtrabackup, pass tmpdir under [xtrabackup] and place it AFTER the [mysqld] section. This will ensure that it is passed to both the target as well as tmpdir options of xtrabackup.

Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :

Looks like tmpdir is passed even from my.cnf.

So, I will keep

=== modified file 'Percona-Server/scripts/wsrep_sst_xtrabackup.sh'
--- Percona-Server/scripts/wsrep_sst_xtrabackup.sh 2012-12-06 13:26:02 +0000
+++ Percona-Server/scripts/wsrep_sst_xtrabackup.sh 2013-04-08 09:21:20 +0000
@@ -97,17 +97,9 @@

     if [ $WSREP_SST_OPT_BYPASS -eq 0 ]
     then
-
- TMPDIR=${TMPDIR:-""}
- if [ -z "${TMPDIR}" ]; then
- # try to get it from my.cnf
- TMPDIR=$(grep -E '^\s*tmpdir' $WSREP_SST_OPT_CONF | \
- awk -F = '{ print $2 }' | sed 's/^\s//g' | sed 's/\s.*//g' )
- # if failed default to /tmp
- [ -z "${TMPDIR}" ] && TMPDIR="/tmp"
- fi
-
- INNOBACKUPEX_ARGS="--galera-info --tmpdir=${TMPDIR} --stream=tar
+ TMPDIR="/tmp"
+
+ INNOBACKUPEX_ARGS="--galera-info --stream=tar
                            --defaults-file=${WSREP_SST_OPT_CONF}
                            --socket=${WSREP_SST_OPT_SOCKET}"

Changed in percona-xtradb-cluster:
milestone: none → 5.5.30-23.7.4
status: Triaged → Fix Released
Revision history for this message
Alex Yurchenko (ayurchen) wrote :

Hm, Raghavendra,

tmpdir value in my.cnf can now be different from one in TMPDIR variable. Note that later TMPDIR value is passed as an argument to innobackupex and later is used to locate xtrabckup PID file.

Is it acceptable that those two values be different?

Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :

@Alex,

The TMPDIR (hardcoded here to /tmp) will mostly be used for
book-keeping files like pid files and others, nothing related to
mysqld (and no issues with O_DIRECT here )

Revision history for this message
Alex Yurchenko (ayurchen) wrote :

So doesn't the actual fix boil down to:

- INNOBACKUPEX_ARGS="--galera-info --tmpdir=${TMPDIR} --stream=tar
+ INNOBACKUPEX_ARGS="--galera-info --stream=tar

? I.e. specifying --tmpdir was an error?

As for TMPDIR value, can it be an arbitrary value or does it have to be exactly "/tmp"? If it can be anything, would it be preferable to be something else? E.g. the same as tmpdir from my.cnf?

Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :

Specifying tmpdir in innobackupex command line can override the ones in my.cnf, so to specify tmpdir and target-dir for xtrabackup - for its log files - the one specified under [xtrabackup] is used.

Now, as far as TMPDIR above is concerned, yes, it was hardcoded to /tmp; yes, it can be anything since it mainly used for pid files etc. and /tmp is present on all systems, it was hardcoded as such.

Changed in codership-mysql:
assignee: nobody → Alex Yurchenko (ayurchen)
milestone: none → 5.5.30-23.7.4
Revision history for this message
Alex Yurchenko (ayurchen) wrote :

fix committed in lp:codership-mysql, r3865

Changed in codership-mysql:
status: New → Fix Committed
Changed in codership-mysql:
status: Fix Committed → Fix Released
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/PXC-1319

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.