Uploaded image for project: 'Percona XtraDB Cluster'
  1. Percona XtraDB Cluster
  2. PXC-2155

wsrep_sst_xtrabackup-v2 not deleting all folders on cleanup

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Pending Release
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: 5.7.21-29.26, 5.6.39-26.25
    • Fix Version/s: 5.6.41, 5.7.23
    • Component/s: None
    • Security Level: Public Bug
    • Labels:
      None

      Description

      wsrep_sst_xtrabackup-v2 uses mktemp to create temporary directories. It makes calls such as below:

      itmpdir=$(mktemp -p "${tmpdirbase}" -dt donor_xb_XXXX)
      

      It issues mktemp passing -t option. From src/mktemp.c file:

      while ((c = getopt_long (argc, argv, "dp:qtuV", longopts, NULL)) != -1)
          {
            switch (c)
              {
      
       . . . 
      
              case 't':
                use_dest_dir = true;
                deprecated_t_option = true;
                break;
      
       . . .
      
              }
          }
      
      . . .
      
         if (deprecated_t_option)
              {
                char *env = getenv ("TMPDIR");
                if (env && *env)
                  dest_dir = env;
                else if (dest_dir_arg && *dest_dir_arg)
                  dest_dir = dest_dir_arg;
                else
                  dest_dir = "/tmp";
      
                if (last_component (template) != template)
                  die (EXIT_FAILURE, 0,
                       _("invalid template, %s, contains directory separator"),
                       quote (template));
              }
      

      This means if TMPDIR is set, it will take precedence over directory passed by -p option. When wsrep_sst_xtrabackup-v2 calls cleanup it only removes tmpdirbase

      cleanup_donor()
      {
      
          . . .
          if [[ -n "${tmpdirbase}" ]]; then
              [[ -d "${tmpdirbase}" ]] && rm -rf "${tmpdirbase}" || true
          fi
         
         . . . 
      
      }
      

      But as files have been created on whatever is set as TMPDIR they will never get removed.

      See below example:

      [root@localhost ~]# export TMPDIR=/tmp
      [root@localhost tmp]# mktemp -p /tmp -dt sst_XXXX
      /tmp/sst_2TXI
      [root@localhost tmp]# mktemp -p /tmp/sst_2TXI -dt joiner_XXXX
      /tmp/joiner_FVsH
      

      joiner folder got created at /tmp/joiner_FVsH while the script expects it to be created at /tmp/sst_2TXI/joiner_FVsH

        Attachments

          Activity

            People

            • Assignee:
              kenn.takara Kenn Takara
              Reporter:
              marcelo.altmann Marcelo Altmann
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 1 hour
                1d 1h