Bug #82499 | Seconds_behind_master is sometimes not NULL despite Slave_IO_Running=NO | ||
---|---|---|---|
Submitted: | 9 Aug 2016 5:32 | Modified: | 14 Sep 2020 21:49 |
Reporter: | Alexander Nemirovsky | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Replication | Severity: | S2 (Serious) |
Version: | 5.6.31 | OS: | Linux |
Assigned to: | CPU Architecture: | Any | |
Tags: | Seconds_Behind_Master, show slave status |
[9 Aug 2016 5:32]
Alexander Nemirovsky
[22 Jun 2018 17:22]
MySQL Verification Team
Hi, I cannot reproduce this! But looks like it might not be a bug after all if you actually did purge the logs. Anyhow no matter how I try I can't get this to happen on a normal master master all best Bogdan
[14 Sep 2020 17:22]
Derek Downey
I was able to reproduce this in 5.7.30 using gtid replication. mysql> SELECT @@version; +-----------+ | @@version | +-----------+ | 5.7.30 | +-----------+ 1 row in set (0.00 sec) mysql> pager grep -E 'Seconds_Behind_Master|Slave_IO_Running|Slave_SQL_Running' PAGER set to 'grep -E 'Seconds_Behind_Master|Slave_IO_Running|Slave_SQL_Running'' mysql> SHOW SLAVE STATUS\G Slave_IO_Running: No Slave_SQL_Running: Yes Seconds_Behind_Master: 0 Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates 1 row in set (0.00 sec) mysql> STOP SLAVE; Query OK, 0 rows affected (0.00 sec) mysql> SHOW SLAVE STATUS\G Slave_IO_Running: No Slave_SQL_Running: No Seconds_Behind_Master: NULL Slave_SQL_Running_State: 1 row in set (0.00 sec) mysql> START SLAVE sql_thread; Query OK, 0 rows affected (0.00 sec) mysql> SHOW SLAVE STATUS\G Slave_IO_Running: No Slave_SQL_Running: Yes Seconds_Behind_Master: 0 Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates 1 row in set (0.01 sec) Steps to reproduce: - load docker-compose file (attached later) - configure replication CHANGE MASTER TO MASTER_HOST = 'sqlthread_primary', MASTER_PORT = 3306, MASTER_USER = 'repl', MASTER_PASSWORD = 'replPass', MASTER_AUTO_POSITION = 1; - only start sql_thread: START SLAVE sql_thread;
[14 Sep 2020 17:23]
Derek Downey
Docker-compose file
Attachment: docker-compose.yml (application/x-yaml, text), 566 bytes.
[14 Sep 2020 17:23]
Derek Downey
Example my.cnf
Attachment: my.cnf (application/octet-stream, text), 62 bytes.
[14 Sep 2020 21:21]
MySQL Verification Team
Hi, Sorry for missunderstanding, I assumed you are seeing value for SBH to be >0 vs NULL but you consider value of 0 to be a bug? Why do you think this is a bug? Thanks Bogdan
[14 Sep 2020 21:40]
Derek Downey
Hi Bogdan, yes I do consider showing a value of 0 for Seconds_behind_master when the Slave_IO_Thread is not running to be a bug. Basically, it should be NULL because it's unknown what the delay is if the I/O thread is not running. I will say that the 5.7 documentation is misleading, as it says two different things. https://dev.mysql.com/doc/refman/5.7/en/show-slave-status.html First: "When no event is currently being processed on the replica, this value is 0." A few paragraphs later: "In MySQL 5.7, this field is NULL (undefined or unknown) if the replica SQL thread is not running, or if the SQL thread has consumed all of the relay log and the replica I/O thread is not running." I consider the second description to be the correct behavior. Regards, Derek From MySQL 5.7 documentation:
[14 Sep 2020 21:49]
MySQL Verification Team
Hi, I agree! Thanks. Verified as described. all best Bogdan
[9 Feb 2023 17:39]
Femi Agbabiaka
log of text replicating the bug
Attachment: replication-bug.txt (text/plain), 12.39 KiB.
[9 Feb 2023 17:41]
Femi Agbabiaka
Hello, I've just attached a log where I replicate this bug. You don't need to be using master-master replication, master-slave will do. When you set master_host to a non-routable address and start slave, Seconds_Behind_Master is set to 0 and never updated, even when the IO thread encounters connection errors.