[MDEV-28720] mariadb-dump creates empty backup without error message/code Created: 2022-05-30  Updated: 2022-10-19  Resolved: 2022-10-19

Status: Closed
Project: MariaDB Server
Component/s: Scripts & Clients
Affects Version/s: None
Fix Version/s: 10.3.37, 10.4.27, 10.5.18, 10.6.11, 10.7.7, 10.8.6, 10.9.4, 10.10.2, 10.11.1

Type: Bug Priority: Major
Reporter: Oli Sennhauser Assignee: Daniel Black
Resolution: Fixed Votes: 0
Labels: beginner-friendly, mariadb-backup
Environment:

Debian 11 / Rocky Linux 8.5


Attachments: PNG File image-2022-09-21-15-23-33-188.png     PNG File screenshot-1.png     PNG File screenshot-2.png    

 Description   

Example (binary logs enabled):

  1. mariadb-dump --user=root --all-databases --flush-logs --master-data=1 --events --triggers --routines > /tmp/full_dump.sql
  2. echo $?
    0
  3. ls -lah /tmp/full_dump.sql
    rw-rr- 1 root root 1.3K May 30 14:56 /tmp/full_dump.sql

Backup is nearly empty...

Reason:

SQL> FLUSH LOGS;
ERROR 1004 (HY000): Can't create file '/var/log/mysqld_error.log' (errno: 13 "Permission denied")

This is really ugly. I would expect a return code Unable to render embedded object: File (= 0 AND an error message) not found.



 Comments   
Comment by kurt.ding [ 2022-09-21 ]

I try this case in my ubuntu computer, but I can't reproduce.
Here is my steps:
1. ./mariadb-dump --user=root --password=111aaa --all-databases --flush-logs --master-data=1 --events --triggers --routines --log-error=/test.log > /tmp/full_dump.sql ,this user isn't permitted to create file in directory /
2 echo $?
exit code is 2
3. check dump output file
it is empty

Comment by kurt.ding [ 2022-09-21 ]

And then I check the code in client/mysqldump.c:7037 , the code is match the case result.

Comment by kurt.ding [ 2022-09-21 ]

So is here another special config you setted or is this case only appear in debian/rocky linux

Comment by Oli Sennhauser [ 2022-09-21 ]

Still reproducible in 10.7.1

shell> mariadb-dump --user=root --all-databases --flush-logs --master-data=1 --events --triggers --routines > /tmp/full_dump.sql
shell> echo $?
0
shell> ll /tmp/full_dump.sql
rw-rw-r- 1 mysql mysql 1266 Sep 21 21:44 /tmp/full_dump.sql

The reason as I described is this:

SQL> FLUSH LOGS;
ERROR 1004 (HY000): Can't create file '/var/log/mysqld_error.log' (errno: 13 "Permission denied")

If the MariaDB Error Log is set to a location where mariadbd is not allowed to write and mariadb-dump does a FLUSH LOGS then the dump seems to be aborted and no error is returned.

so just set log_error = /root/error.log

And you should immediately get the problem.

Comment by kurt.ding [ 2022-09-22 ]

I understand what you mean , you set the log_error= /root/error.log within mysqld cnf . So I add an error message like this.

Comment by kurt.ding [ 2022-09-22 ]

Comment by kurt.ding [ 2022-09-22 ]

PR is https://github.com/MariaDB/server/pull/2276

Comment by Daniel Black [ 2022-10-19 ]

Thanks Kurt Ding, rebased to 10.3 and added MDEV to commit.

Tested manually:

$ mariadblocal --log-error=/tmp/m.err
Installing MariaDB/MySQL system tables in '/tmp/build-mariadb-server-10.3-datadir' ...
2022-10-19 15:28:46 0 [Note] /home/dan/repos/build-mariadb-server-10.3/sql/mysqld (mysqld 10.3.37-MariaDB) starting as process 113985 ...
2022-10-19 15:28:46 0 [Note] InnoDB: Using Linux native AIO
2022-10-19 15:28:46 0 [Note] InnoDB: The first innodb_system data file 'ibdata1' did not exist. A new tablespace will be created!
2022-10-19 15:28:46 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2022-10-19 15:28:46 0 [Note] InnoDB: Uses event mutexes
2022-10-19 15:28:46 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2022-10-19 15:28:46 0 [Note] InnoDB: Number of pools: 1
2022-10-19 15:28:46 0 [Note] InnoDB: Using SSE2 crc32 instructions
2022-10-19 15:28:46 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2022-10-19 15:28:46 0 [Note] InnoDB: Completed initialization of buffer pool
2022-10-19 15:28:46 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2022-10-19 15:28:46 0 [Note] InnoDB: Setting file './ibdata1' size to 12 MB. Physically writing the file full; Please wait ...
2022-10-19 15:28:46 0 [Note] InnoDB: File './ibdata1' size is now 12 MB.
2022-10-19 15:28:46 0 [Note] InnoDB: Setting log file ./ib_logfile101 size to 50331648 bytes
2022-10-19 15:28:46 0 [Note] InnoDB: Setting log file ./ib_logfile1 size to 50331648 bytes
2022-10-19 15:28:46 0 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2022-10-19 15:28:46 0 [Note] InnoDB: New log files created, LSN=44897
2022-10-19 15:28:46 0 [Note] InnoDB: Doublewrite buffer not found: creating new
2022-10-19 15:28:46 0 [Note] InnoDB: Doublewrite buffer created
2022-10-19 15:28:46 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2022-10-19 15:28:46 0 [Note] InnoDB: Creating foreign key constraint system tables.
2022-10-19 15:28:46 0 [Note] InnoDB: Creating tablespace and datafile system tables.
2022-10-19 15:28:46 0 [Note] InnoDB: Creating sys_virtual system tables.
2022-10-19 15:28:46 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2022-10-19 15:28:46 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2022-10-19 15:28:46 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2022-10-19 15:28:46 0 [Note] InnoDB: Waiting for purge to start
2022-10-19 15:28:46 0 [Note] InnoDB: 10.3.37 started; log sequence number 0; transaction id 7
OK
2022-10-19 15:28:48 0 [Note] sql/mysqld (mysqld 10.3.37-MariaDB) starting as process 114016 ...
..

$ ls -la /tmp/m.err
-rw-rw----. 1 dan dan 1850 Oct 19 15:28 /tmp/m.err
 
$ chmod 0000 /tmp/m.err
 
$ client/mysqldump -u root --all-databases --flush-logs --master-data=1 --events --triggers --routines   -S /tmp/build-mariadb-server-10.3.sock
-- MySQL dump 10.19  Distrib 10.3.37-MariaDB, for Linux (x86_64)
--
-- Host: localhost    Database: 
-- ------------------------------------------------------
-- Server version	10.3.37-MariaDB
 
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES latin1 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
Flush logs or delete master logs failure in server 
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
 
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
 
-- Dump completed on 2022-10-19 15:31:18
 
$ echo $?
2

Comment by Daniel Black [ 2022-10-19 ]

Thanks oli and Kurt Ding. Will be out next release

Generated at Thu Feb 08 10:02:57 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.