Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-4734

Adding ending / to a directory can fail when the directory ends with 0

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Fixed
    • 10.0.3
    • 10.0.6
    • None

    Description

      The rpl_binlog_index.test fails to clean up $tmpdir because files still exist. The files aren't cleaned up due to a missing slash in the tmpdir path.

      Logging: ./mysql-test-run  rpl_binlog_index
      vardir: /home/ebergen/bzr/maria/trunk/mysql-test/var
      Checking leftover processes...
      Removing old var directory...
      Creating var directory '/home/ebergen/bzr/maria/trunk/mysql-test/var'...
      Checking supported features...
      MariaDB Version 10.0.3-MariaDB
      Installing system database...
       - skipping SSL, mysqld not compiled with SSL
      Collecting tests...
      Using server port 36585
       
      ==============================================================================
       
      TEST                                      RESULT   TIME (ms) or COMMENT
      --------------------------------------------------------------------------
       
      worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 16000..16019
      rpl.rpl_binlog_index 'row'               [ fail ]
              Test ended at 2013-06-29 15:46:08
       
      CURRENT_TEST: rpl.rpl_binlog_index
      /home/ebergen/bzr/maria/trunk/client/mysqltest: Error on delete of '/home/ebergen/bzr/maria/trunk/mysql-test/var/mysqld.2/data//slave-relay-bin.index' (Errcode: 2 "No such file or directory")
      /home/ebergen/bzr/maria/trunk/client/mysqltest: Error on delete of '/home/ebergen/bzr/maria/trunk/mysql-test/var/mysqld.2/data//relay-log.info' (Errcode: 2 "No such file or directory")
      /home/ebergen/bzr/maria/trunk/client/mysqltest: Can't get stat of '/home/ebergen/bzr/maria/trunk/mysql-test/var/tmp/833775f7-e0f4-11e2-bb3f-00224d9f45a0master-bin.state' (Errcode: 2 "No such file or directory")
      /home/ebergen/bzr/maria/trunk/client/mysqltest: Can't get stat of '/home/ebergen/bzr/maria/trunk/mysql-test/var/tmp/833775f7-e0f4-11e2-bb3f-00224d9f45a0slave-bin.000003' (Errcode: 2 "No such file or directory")
      /home/ebergen/bzr/maria/trunk/client/mysqltest: Can't get stat of '/home/ebergen/bzr/maria/trunk/mysql-test/var/tmp/833775f7-e0f4-11e2-bb3f-00224d9f45a0slave-bin.000002' (Errcode: 2 "No such file or directory")
      /home/ebergen/bzr/maria/trunk/client/mysqltest: Can't get stat of '/home/ebergen/bzr/maria/trunk/mysql-test/var/tmp/833775f7-e0f4-11e2-bb3f-00224d9f45a0slave-bin.state' (Errcode: 2 "No such file or directory")
      mysqltest: At line 193: command "rmdir" failed with error: 1  my_errno: 2  errno: 39

      Attachments

        Activity

          Just in case, I re-checked it on Fedora 18 64-bit with BUILD/compile-pentium64 (as discussed on IRC). As expected, still no failure.

          According to mysqltest code, the trailing slash should not be needed. The test fails to remove files in remove_files_wildcard

          191: --echo # remove tmpdir
          192: --remove_files_wildcard $tmpdir *
          193: --rmdir $tmpdir

          But mysqltest in do_remove_files_wildcard explicitly adds a separator after a dirname:

          init_dynamic_string(&ds_file_to_remove, dirname, 1024, 1024);
          dir_separator[0]= FN_LIBCHAR;
          dynstr_append_mem(&ds_file_to_remove, dir_separator, 1);
          directory_length= ds_file_to_remove.length;

          And FN_LIBCHAR is defined in my_global.h:

          #ifdef _WIN32
          #define FN_LIBCHAR '
          '
          ...
          #else
          #define FN_LIBCHAR '/'
          ...
          #endif

          Since you are building from sources anyway, can you add a debugging print or run mysqltest under debugger to see what your FN_LIBCHAR is in mysqltest.cc:do_remove_files_wildcard ?

          Could you please also run the following test to see how it goes?

          --let $dirname= `SELECT uuid()`
          --let $tmpdir= $MYSQLTEST_VARDIR/$dirname
          --mkdir $tmpdir
          --write_file $tmpdir/abcd.file
          test
          EOF

          --list_files $MYSQLTEST_VARDIR/$dirname *

          --remove_files_wildcard $tmpdir *
          --rmdir $tmpdir
          --echo # All good

          1. End of test

          Thanks.

          elenst Elena Stepanova added a comment - Just in case, I re-checked it on Fedora 18 64-bit with BUILD/compile-pentium64 (as discussed on IRC). As expected, still no failure. According to mysqltest code, the trailing slash should not be needed. The test fails to remove files in remove_files_wildcard 191: --echo # remove tmpdir 192: --remove_files_wildcard $tmpdir * 193: --rmdir $tmpdir But mysqltest in do_remove_files_wildcard explicitly adds a separator after a dirname: init_dynamic_string(&ds_file_to_remove, dirname, 1024, 1024); dir_separator [0] = FN_LIBCHAR; dynstr_append_mem(&ds_file_to_remove, dir_separator, 1); directory_length= ds_file_to_remove.length; And FN_LIBCHAR is defined in my_global.h: #ifdef _WIN32 #define FN_LIBCHAR ' ' ... #else #define FN_LIBCHAR '/' ... #endif Since you are building from sources anyway, can you add a debugging print or run mysqltest under debugger to see what your FN_LIBCHAR is in mysqltest.cc:do_remove_files_wildcard ? Could you please also run the following test to see how it goes? --let $dirname= `SELECT uuid()` --let $tmpdir= $MYSQLTEST_VARDIR/$dirname --mkdir $tmpdir --write_file $tmpdir/abcd.file test EOF --list_files $MYSQLTEST_VARDIR/$dirname * --remove_files_wildcard $tmpdir * --rmdir $tmpdir --echo # All good End of test Thanks.
          ebergen Eric Bergen added a comment -

          I dug a bit further into both the rpl_binlog_index test failure and the failure you sent me. They both fail on BUILD/compile-pentium64-debug. While it was in debug mode I was able to trace the problem down to some strange code in mysys/my_lib.c:102 it does a comparison against FN_LIBCHAR + 1 which seems to fail. Below that it would add a trailing slash if it succeeds. By removing the + 1 the test you gave me and rpl_binlog_index both succeed.

          The code in mysqltest.cc to add the trailing slash happens after the call to my_dir.

          ebergen Eric Bergen added a comment - I dug a bit further into both the rpl_binlog_index test failure and the failure you sent me. They both fail on BUILD/compile-pentium64-debug. While it was in debug mode I was able to trace the problem down to some strange code in mysys/my_lib.c:102 it does a comparison against FN_LIBCHAR + 1 which seems to fail. Below that it would add a trailing slash if it succeeds. By removing the + 1 the test you gave me and rpl_binlog_index both succeed. The code in mysqltest.cc to add the trailing slash happens after the call to my_dir.
          elenst Elena Stepanova added a comment - - edited

          Thanks Nice finding.
          It so happens that your uuid() end with a zero (mine don't); and the comparison with FN_LIBCHAR + 1 is basically with 0, right?

          When I force a directory name to add with 0, it fails for me too. And I suppose for you the one below will pass (the only difference with the previous one is that I concatenate uuid() with '1':

          --let $dirname= `SELECT CONCAT(uuid(),'1')`
          --echo # Dirname: $dirname
          --let $tmpdir= $MYSQLTEST_VARDIR/$dirname
          --mkdir $tmpdir
          --write_file $tmpdir/abcd.file
          test
          EOF

          --list_files $MYSQLTEST_VARDIR/$dirname *

          --remove_files_wildcard $tmpdir *
          --rmdir $tmpdir
          --echo # All good

          elenst Elena Stepanova added a comment - - edited Thanks Nice finding. It so happens that your uuid() end with a zero (mine don't); and the comparison with FN_LIBCHAR + 1 is basically with 0, right? When I force a directory name to add with 0, it fails for me too. And I suppose for you the one below will pass (the only difference with the previous one is that I concatenate uuid() with '1': --let $dirname= `SELECT CONCAT(uuid(),'1')` --echo # Dirname: $dirname --let $tmpdir= $MYSQLTEST_VARDIR/$dirname --mkdir $tmpdir --write_file $tmpdir/abcd.file test EOF --list_files $MYSQLTEST_VARDIR/$dirname * --remove_files_wildcard $tmpdir * --rmdir $tmpdir --echo # All good
          ebergen Eric Bergen added a comment -

          I reworked directory_file_name to compare the ending character against '/' and it passes tests with my 0 uuid. The patch for this version is MDEV_4734_2.patch

          ebergen Eric Bergen added a comment - I reworked directory_file_name to compare the ending character against '/' and it passes tests with my 0 uuid. The patch for this version is MDEV_4734_2.patch

          Only 10.0 is affected, there was some refactoring in there.

          Test case for completion (be careful while copying it, make sure there are no leading or trailing spaces):

          --let $mydir= $MYSQLTEST_VARDIR/dir0
          --mkdir $mydir
          --write_file $mydir/foo
          bar
          EOF

          --remove_files_wildcard $mydir *
          --rmdir $mydir

          --echo # All good

          See the patch proposed by Eric.

          elenst Elena Stepanova added a comment - Only 10.0 is affected, there was some refactoring in there. Test case for completion (be careful while copying it, make sure there are no leading or trailing spaces): --let $mydir= $MYSQLTEST_VARDIR/dir0 --mkdir $mydir --write_file $mydir/foo bar EOF --remove_files_wildcard $mydir * --rmdir $mydir --echo # All good See the patch proposed by Eric.

          People

            serg Sergei Golubchik
            ebergen Eric Bergen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.