[MDEV-4734] Adding ending / to a directory can fail when the directory ends with 0 Created: 2013-06-29  Updated: 2013-11-10  Resolved: 2013-11-10

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.0.3
Fix Version/s: 10.0.6

Type: Bug Priority: Minor
Reporter: Eric Bergen Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: tests
Environment:

Fedora 18. bzr pull from lp:maria trunk
bzr version-info
revision-id: svoj@mariadb.org-20130627111848-b8kc0z60ywwpqavz
date: 2013-06-27 15:18:48 +0400
build-date: 2013-06-29 15:42:46 -0400
revno: 3762
branch-nick: trunk


Attachments: Text File MDEV_4734.patch     Text File MDEV_4734_2.patch    

 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



 Comments   
Comment by Elena Stepanova [ 2013-06-30 ]

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.

Comment by Eric Bergen [ 2013-07-01 ]

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.

Comment by Elena Stepanova [ 2013-07-01 ]

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

Comment by Eric Bergen [ 2013-07-01 ]

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

Comment by Elena Stepanova [ 2013-07-01 ]

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.

Generated at Thu Feb 08 06:58:43 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.