[MDEV-17642] mysqldump restore with specified databases wont set gtid Created: 2018-11-08  Updated: 2018-11-13  Resolved: 2018-11-13

Status: Closed
Project: MariaDB Server
Component/s: Backup, Replication
Affects Version/s: 10.1.28
Fix Version/s: 10.1.28

Type: Bug Priority: Major
Reporter: Su, Jun-Ming Assignee: Andrei Elkin
Resolution: Not a Bug Votes: 0
Labels: None
Environment:

Windows Server 2012 R2



 Description   

I have a MariaDB Master (called A) with binlog, and a MariaDB Slave (called B) to A for some specified databases.

Now I need to create another MariaDB Slave (called C) to A for some specified databases which different replicate from B.

I install MariaDB, and restore with backup from mysqldump with gtid and master-data flags for specified databases. (with{{ -D database -o database}})

After complete restoration and start the slave, it says slave_io_process error, can not get latest binlog.

I get into troubleshooting for this problem, and find there is no value in mysql.gtid_slave_pos.

So I need to login to A and get the gtid from binlog and set it in C.

But if I restore ALL database in C, there is value in mysql.gtid_slave_pos in C.

Why do the specified databases restore will not execute set global gtid_slave_pos in dumpfile?



 Comments   
Comment by Andrei Elkin [ 2018-11-09 ]

Hello, Jun-Ming.

Thanks for reporting!
I would be very helpful to write down how to reproduce what you experienced.

If I got it right, the problem seems to be in that mysqldump output misses out
SET GLOBAL gtid_slave_pos='value'
setting. That would explain 'no value in mysql.gtid_slave_pos.'
And this happens when mysqldump runs on 'specified databases', not all databases.

I checked this assumption to execute

mysqldump --host 127.0.0.1 --port 20560 --user root --gtid --master-data=1 test 

only see

CHANGE MASTER TO MASTER_USE_GTID=slave_pos;
SET GLOBAL gtid_slave_pos='0-1-20';

in place. I did not restore the dump neither start slave being content with
the fact of created gtid_slave_pos.

I suggest you describe it in step by step, or just give us a script that reproduces
your description.

Cheers,

Andrei

Comment by Su, Jun-Ming [ 2018-11-09 ]

Thanks for your reply.

The following is to reproduce my problem.

1. mysqldump with gtid and master-data flags in Server A

E:\backup>mysqldump -u sujunmin -p --master-data --all-databases --events --routines --gtid > all_db.sql
Enter password: ************

And in the beginning of all_db.sql is

-- MySQL dump 10.28  Distrib 10.1.28-MariaDB, for Win64 (AMD64)
(deleted)
--
-- Position to start replication or point-in-time recovery from
--
 
-- CHANGE MASTER TO MASTER_LOG_FILE='WSTest-bin.000002', MASTER_LOG_POS=3732;
 
--
-- GTID to start replication from
--
 
CHANGE MASTER TO MASTER_USE_GTID=slave_pos;
SET GLOBAL gtid_slave_pos='0-1-770';
 
--
-- Current Database: 'master'
--
(deleted)

2. Restore with specified Databases in Server C
a. Create database spec_db
b.

E:\backup>mysql -u root -p -D spec_db -o spec_db < all_db.sql
Enter password: ************

c. There is no value in mysql.gtid_slave_pos
d. start slave failed because there is no value in mysql.gtid_slave_pos.

3. Restore with ALL Databases in Server C
a.

E:\backup>mysql -u root -p < all_db.sql
Enter password: ************

b.
There is a value (0-1-770) in mysql.gtid_slave_pos
c.
start slave OK.

Comment by Andrei Elkin [ 2018-11-12 ]

Thanks for how-to-reproduce details! I think I understood what was your problem,
and tried your 1, 2 a,b,c steps only to find that at 2c mysql.gtid_slave_pos has something for me:

MariaDB [test]> select * from mysql.gtid_slave_pos;
+-----------+--------+-----------+--------+
| domain_id | sub_id | server_id | seq_no |
+-----------+--------+-----------+--------+
|         0 |      1 |         1 |      2 |
+-----------+--------+-----------+--------+
 
MariaDB [test]> select @@global.gtid_slave_pos;
+-------------------------+
| @@global.gtid_slave_pos |
+-------------------------+
| 0-1-2                   |
+-------------------------+

I check both the current your 10.1.28 but only on Linux.

MariaDB [test]> show global variables like 'version';
+---------------+-----------------------+
| Variable_name | Value                 |
+---------------+-----------------------+
| version       | 10.1.28-MariaDB-debug |
+---------------+-----------------------+

I also the query log on my server "C" to confirm that no queries from other databases but spec_db
were executed in 2b. And that clearly complies with -o of mysql client program:

Could you check your query log ? What if you will find mysql database queries in there? Specifically DROP,CREATE for gtid_slave_pos?
That could explain the empty output (I am guessing) of your_ c. There is no value in mysql.gtid_slave_pos_.
However even in this case the global variable contains the dump's value:

MariaDB [mysql]> select @@global.gtid_slave_pos;+-------------------------+
| @@global.gtid_slave_pos |
+-------------------------+
| 0-1-2                   |
+-------------------------+

also for you verify. Thank you.

And if that's the case it would be mysql client issue for which you have not reported the version.

Cheers.

Andrei

Comment by Su, Jun-Ming [ 2018-11-13 ]

I had tried the process again and got the right answer: the gtid_slave_pos would be a value even restore all or specified databases, maybe another issues for this problem. please close this issue, thanks.

Comment by Andrei Elkin [ 2018-11-13 ]

Thanks you Jun-Ming! We can only appreciate efforts like yours always contributing to quality of mariadb!

Comment by Andrei Elkin [ 2018-11-13 ]

The user sorted it out through discussion with myself.

Generated at Thu Feb 08 08:38:00 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.