Bug #34754 Backup: Invalid error message for incorrect path name while performing backup
Submitted: 22 Feb 2008 2:10 Modified: 13 Dec 2008 17:14
Reporter: Hema Sridharan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Backup Severity:S3 (Non-critical)
Version:mysql-6.0-backup OS:Linux
Assigned to: Øystein Grøvlen CPU Architecture:Any

[22 Feb 2008 2:10] Hema Sridharan
Description:
1) I create a database and few tables in it.
2) I try to backup the database to one particular location (local file)
3) I try to backup database again by giving invalid path name. (to a non-existing directory)
4) I get the error message saying that "can't write backup to a location as file already exists". Here the file already exists shouldn't be the message, as there is no such file. This error message is misleading.

Instead the message should be "invalid path name" or "No such directory". 
  

How to repeat:
1) I create a database err.
2) I create tables eht1_dt and eht2_dtu
3) I backup this database to the local file named errb ('/data2/hema/backup_dmp/errb')

4) Now I tried to backup the same database by giving invalid path name

mysql> backup database err to '/data2/hema/buju/kuju';
ERROR 1614 (HY000): Can't write to backup location '/data2/hema/buju/kuju' (file already exists?)

(Folder 'buju' doesn't exist, so 'file already exists' message doesn't seem to be appropriate)

mysql> backup database err to '/data1/found/err';
ERROR 1614 (HY000): Can't write to backup location '/data1/found/err' (file already exists?)

The error message given here is invalid as you can always backup the same database many times by giving different destination file name, but the path should be valid. 

In this case the error message should be "Invalid path name" or "No such file or directory"

Suggested fix:
While performing backup with invalid path name , the error message should indicate the specific reason.
[22 Feb 2008 14:26] MySQL Verification Team
Thank you for the bug report.
[26 Mar 2008 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[27 Mar 2008 19:05] Hema Sridharan
MTR test for the Bug#34754

--error 0,1
--remove_file $MYSQLTEST_VARDIR/master-data/try.bak

#Create Database
        
--disable_warnings
DROP DATABASE IF EXISTS try;
--enable_warnings

CREATE DATABASE try;
USE try;

#Create table and load with data.

--echo Creating table
CREATE TABLE t1(name char(10), id int)ENGINE=MYISAM;

CREATE TABLE t2(city varchar(20), state char(10))ENGINE=MYISAM;

--echo loading data
INSERT INTO t1 VALUES('aa',1),('bb',2);

INSERT INTO t2 VALUES('austin','TX'),('sfo','CA');

#selecting data

SELECT * FROM t1;

SELECT * FROM t2;
    
#Backup and restore data.
--echo backup data

BACKUP DATABASE try TO 'try.bak';

#In doing BACKUP give invalid path name and check for error message.
#BUG#34754

#I get the error message saying that "can't write backup to a location as file already exists". Here the file already exists shouldn't be the message, as there is no such file.This error message is misleading.

#Instead the message should be "invalid path name" or "No such directory".
#Also the error message given here is invalid as you can always backup the same database many times by giving different destination file name, but the path should be valid.

--error 1628
BACKUP DATABASE try TO '/data2/heman/buju/kuju';
ERROR HY000: Can't write to backup location '/data2/heman/buju/kuju' (file already exists?)

Verified using test framework as described.
[14 Nov 2008 7:54] Øystein Grøvlen
Just to be clear:  The error message is the same regardles of whether a successful backup was performed first.
[18 Nov 2008 14:21] Øystein Grøvlen
The error message for SELECT ... INTO OUTFILE is not more specific either when path is invalid:

select * from t into outfile '/home/hema/a.txt';
ERROR 1 (HY000): Can't create/write to file '/home/hema/a.txt' (Errcode: 2)
[24 Nov 2008 16:06] Øystein Grøvlen
Stream::open() calls my_open() with flags MYF(0).  This will not generate an error message on errors.  Instead, MYF(MY_WME) should be used.  In addition, my_create() should be used instead of my_open() to get "Can't create/write to file '%s' (Errcode: %d)", which is more appropriate than "File '%s' not found (Errcode: %d)" reported by my_open()
[26 Nov 2008 14:08] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/59937

2736 oystein.grovlen@sun.com	2008-11-26
      BUG#34754 Backup: Invalid error message for incorrect path name while performing backup
      
      Will now use error messages generated by my_create (BACKUP) and my_open (RESTORE)
      when failing to create/open a file since these message are more specific as to
      the cause of the failure.
      
      Note that the backup-specific errors will still be pushed on the error stack
      and it is still the backup-specific errors that are recorded in the the backup
      history log and in the error file.
[3 Dec 2008 14:52] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/60494

2737 oystein.grovlen@sun.com	2008-12-03
      BUG#34754 Backup: Invalid error message for incorrect path name while performing backup
      
      Will now use error messages generated by my_create (BACKUP) and my_open (RESTORE)
      when failing to create/open a file since these message are more specific as to
      the cause of the failure.
      
      Note that the backup-specific errors will still be pushed on the error stack,
      and it is still these errors that are recorded in the backup history log and 
      in the error file.
[3 Dec 2008 15:04] Øystein Grøvlen
Just to clarify one of my previous comments.  In order to get appropriate error messages, my_create() should be used when creating the file for the backup image, and my_open() should be used when opening the backup image on restore.
[3 Dec 2008 16:39] Chuck Bell
Patch approved.
[8 Dec 2008 9:22] Rafal Somla
Approved.
[8 Dec 2008 11:25] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/60879

2733 oystein.grovlen@sun.com	2008-12-08
      BUG#34754 Backup: Invalid error message for incorrect path name while performing backup
      
      Will now use error messages generated by my_create (BACKUP) and my_open (RESTORE)
      when failing to create/open a file since these message are more specific as to
      the cause of the failure.
      
      Note that the backup-specific errors will still be pushed on the error stack,
      and it is still these errors that are recorded in the backup history log and 
      in the error file.
[8 Dec 2008 11:35] Øystein Grøvlen
Patch pushed to mysql-6.0-backup with revision id
oystein.grovlen@sun.com-20081208112451-9bw0jy4xvlllitg2
[12 Dec 2008 6:25] Bugs System
Pushed into 6.0.9-alpha  (revid:oystein.grovlen@sun.com-20081208112451-9bw0jy4xvlllitg2) (version source revid:oystein.grovlen@sun.com-20081208112451-9bw0jy4xvlllitg2) (pib:5)
[13 Dec 2008 17:14] Paul DuBois
Noted in 6.0.9 changelog.

BACKUP DATABASE produced an incorrect error message when the backup
image filename contained a nonexistent directory.