Bug #60013 MEB gets confused by directories inside database directories
Submitted: 8 Feb 2011 18:24 Modified: 16 Feb 2011 9:37
Reporter: Hema Sridharan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Enterprise Backup Severity:S3 (Non-critical)
Version:MEB 3.6 OS:Any
Assigned to: Thava Alagu CPU Architecture:Any

[8 Feb 2011 18:24] Hema Sridharan
Description:
Execute mysqlbackup such that backup directory is made as sub dir of data dir.
Backup starts and creates a meta.dir directory inside backup directory and then 
it fails giving an error as 
Error: Problem found with datadir configuration.
	The destination dir can not be subdir of source dir.

Now execute backup again with different backup directory, it will fail with an 
error "mysqlbackup: Error reading file '/export/home2/tmp/mysql-5.1-meb-testing/mysql-test/var/mysqld.1/data/mebdir/meta.dir' (Errcode: 21)"

Mysqlbackup looks for only files inside database directories. It gets confused 
by directories(meta.dir) inside database dir. Due to this it issues "Error reading file".

How to repeat:
1. First run backup with backup dir inside data dir 
 ./mysqlbackup --datadir=/export/home2/tmp/mysql-5.1-meb-testing/mysql-
test/var/mysqld.1/data/ --innodb_log_file_size=5M --innodb_log_files_in_group=4 
--backup_innodb_log_fies_in_group=4 --backup_innodb_log_file_size=5M --
innodb_data_home_dir=/export/home2/tmp/mysql-5.1-meb-testing/mysql-
test/var/mysqld.1/data/ --backup-dir=/expor/home2/tmp/mysql-5.1-meb-
testing/mysql-test/var/mysqld.1/data/mebdir/ --socket=/export/home2/tmp/mysql-
5.1-meb-testing/mysql-test/var/tmp/mysqld.1.sock --user=root --port=13000 --
protocol=tcp backup

Now this will fail with error 
Error: Problem found with datadir configuration.
	The destination dir can not be subdir of source dir.

2. Then again run backup with different backup dir location (say --backup-
dir=export/home2/tmp/bkpdir)

The above command will result in error as 
mysqlbackup: Error reading file '/export/home2/tmp/mysql-5.1-meb-testing/mysql-
test/var/mysqld.1/data/mebdir/meta.dir' (Errcode: 21)

If you notice, mysqlbackup searches for only files inside the database directories and gets confused if it sees directory(meta.dir).
[10 Feb 2011 19:03] Valeriy Kravchuk
Verified on Mac OS X with a bit more simple (but more artificial) test case. I've just created directory in data/test directory, and then:

macbook-pro:meb-3.6 openxs$ bin/mysqlbackup --comments=OPENXS --comments-file=/tmp/comments.txt -uroot --backup-dir=/tmp/backup backup

InnoDB Backup Utility v3.6.0 [2011/02/10] 
Copyright (c) 2003, 2011, Oracle and/or its affiliates. All Rights Reserved.

INFO: Starting with following command line ...
 bin/mysqlbackup --comments=OPENXS --comments-file=/tmp/comments.txt 
        -uroot --backup-dir=/tmp/backup backup 

INFO: Got some server configuration information from running server.

Created backup directory '/tmp/backup'
IMPORTANT: Please check that mysqlbackup run completes successfully.
            At the end of a successful 'backup' run mysqlbackup
            prints "mysqlbackup completed OK!".

--------------------------------------------------------------------
                       Server Repository Options:
--------------------------------------------------------------------
  datadir                          =  /Users/openxs/dbs/5.5/data/
  innodb_data_home_dir             =  
  innodb_data_file_path            =  ibdata1:10M:autoextend
  innodb_log_group_home_dir        =  /Users/openxs/dbs/5.5/data/
  innodb_log_files_in_group        =  2
  innodb_log_file_size             =  5242880

--------------------------------------------------------------------
                       Backup Config Options:
--------------------------------------------------------------------
  datadir                          =  /tmp/backup
  innodb_data_home_dir             =  /tmp/backup
  innodb_data_file_path            =  ibdata1:10M:autoextend
  innodb_log_group_home_dir        =  /tmp/backup
  innodb_log_files_in_group        =  2
  innodb_log_file_size             =  5242880

 mysqlbackup: INFO: Unique generated backup id for this is 12973644415936530 
 mysqlbackup: INFO: System tablespace file format is Antelope.
 mysqlbackup: INFO: Found checkpoint at lsn 1740123.
 mysqlbackup: INFO: Starting log scan from lsn 1739776.
110210 21:00:41 mysqlbackup: INFO: Copying log...
110210 21:00:41 mysqlbackup: INFO: Log copied, lsn 1740123.
          We wait 1 second before starting copying the data files...
110210 21:00:42 mysqlbackup: INFO: Copying /Users/openxs/dbs/5.5/data/ibdata1 (Antelope file format).
 mysqlbackup: INFO: Preparing to lock tables: Connected to mysqld server.
110210 21:00:43 mysqlbackup: INFO: Starting to lock all the tables....
110210 21:00:43 mysqlbackup: INFO: All tables are locked and flushed to disk
 mysqlbackup: INFO: Opening backup source directory '/Users/openxs/dbs/5.5/data/'
110210 21:00:43 mysqlbackup: INFO: Starting to backup all files in subdirectories of '/Users/openxs/dbs/5.5/data/'
 mysqlbackup: INFO: Backing up the database directory 'mysql'
 mysqlbackup: INFO: Backing up the database directory 'performance_schema'
 mysqlbackup: INFO: Backing up the database directory 's1'
 mysqlbackup: INFO: Backing up the database directory 's2'
 mysqlbackup: INFO: Backing up the database directory 'test'
mysqlbackup: Error reading file '/Users/openxs/dbs/5.5/data/test/deleteme' (Errcode: 21)
 mysqlbackup: ERROR: Cannot backup table `test`.`deleteme`
 mysqlbackup: ERROR: Cannot backup database 'test'
 mysqlbackup: ERROR: Backup of non-innodb tables failed.!
110210 21:00:43 mysqlbackup: INFO: All tables unlocked
Error: operation failed.
[15 Feb 2011 17:09] Thava Alagu
There 2 separate issues:

Issue 1:
The backup directory should not be sub directory of data directory to prevent recursive copying of itself. This is by design and not a bug. 

Issue 2:
  Failure when database dir containing subdirectory.
 We don't expect sub directories in database directory. Is there any specific reason to support this ?

If not, I will close this bug.
[15 Feb 2011 17:41] Hema Sridharan
Hi Thava,

1. We don't expect backup dir to be sub dir of data dir and it does issue an error message for it. But after that, when we try to run the mysqlbackup once again..then it issues an error message as 
"mysqlbackup: Error reading file
'/export/home2/tmp/mysql-5.1-meb-testing/mysql-test/var/mysqld.1/data/mebdir/meta.dir'
(Errcode: 21)"

The above message means that mysqlbackup looks for only files inside the database directories and gets confused by seeing meta.dir. We expect that mysqlbackup should issue an error message as Error reading the directory.. or some such.

2. There is no specific reason to support sub directories inside the database dir. But we do expect that it should give appropriate error message. Pls also see related BUG#60014 

This bug report should fix the error message that occurs when running mysqlbackup for the 2nd time.
[15 Feb 2011 17:57] Thava Alagu
There is nothing special about meta.dir that should confuse MEB. In production systems, there should never be meta.dir subdir in datadir. If there is one, it will treat it like a database name. What is not allowed is a subdir inside database dir. In such cases the error message could be better. Since that is also included in Bug#60014, I suggest to close this one, and keep the other open.
[16 Feb 2011 9:37] Thava Alagu
The concerns raised has been addressed in the latest patch.