# Strange Seconds\_Behind\_Master behavior

**URL:** <https://forums.percona.com/t/strange-seconds-behind-master-behavior/31349>\
**Category:** Percona Server for MySQL 5.7\
**Created:** [July 2, 2024, 10:51am UTC](https://forums.percona.com/t/strange-seconds-behind-master-behavior/31349 "2024-07-02T10:51:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deniska80](https://avatars.discourse-cdn.com/v4/letter/d/db5fbb/32.png) [@Deniska80](https://forums.percona.com/u/Deniska80)\
**Post date:** [July 2, 2024, 10:51am UTC](https://forums.percona.com/t/strange-seconds-behind-master-behavior/31349/1 "2024-07-02T10:51:44Z")

</div>

Hello, i’ve got one master and two replics from this master (all the same versions 5.7.44-48-log), it’s GTID replication. One replica works fine, and the second one has issue.  
It’s “Seconds\_Behind\_Master” value constantly changes: i mean it’s 0 for several ‘show slave status’ command, and then, after several seconds it’s become much more - 3836 for example. Next call show slave status immediatly shows 0 again.  
No errors in log-files, “Slave\_IO\_Running” and “Slave\_SQL\_Running” always Yes, time on all servers are the same and ntp synced.  
In fact - this replica is far beyond master, but why then it almost always show “Seconds\_Behind\_Master”: 0? And when it’s 0 “Retrieved\_Gtid\_Set” and “Executed\_Gtid\_Set” are the same.  
From monitoring tool it’s look like this

 ![Screenshot 2024-07-02 135103](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/3X/0/2/0207e4b1ba8cb4fb8e7f64ab2a3bedd0d2babffa.png)

Anyone has some clue?

---

<div class="post-metadata">

**Author:** ![Deniska80](https://avatars.discourse-cdn.com/v4/letter/d/db5fbb/32.png) [@Deniska80](https://forums.percona.com/u/Deniska80)\
**Post date:** [July 3, 2024, 6:03am UTC](https://forums.percona.com/t/strange-seconds-behind-master-behavior/31349/2 "2024-07-03T06:03:03Z")

</div>

Ok, i stoped this strange replica, made xtrabackup from master (as always), transfer files snd start replica again. It’s all takes about 14 hours. Ok, i started replica again and this strange behavior sill there ^(  
One seconds ‘show slave status’ shows  
…  
Seconds\_Behind\_Master: 51211  
Slave\_SQL\_Running\_State: Reading event from the relay log  
…  
another seconds it show  
…  
Seconds\_Behind\_Master: 0  
Slave\_SQL\_Running\_State: Slave has read all relay log; waiting for more updates  
…

Don’t have any idea, why is ths

---

<div class="post-metadata">

**Author:** ![kedarpercona](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/kedarpercona/32/809_2.png) [@kedarpercona](https://forums.percona.com/u/kedarpercona)\
**Post date:** [July 3, 2024, 6:21am UTC](https://forums.percona.com/t/strange-seconds-behind-master-behavior/31349/3 "2024-07-03T06:21:13Z")

</div>

Hi @Deniska80,

What was the replica executing while you saw the increased lag?  
Did you see while your lag was increasing did you have exec\_master\_log\_pos moving?  
Is the binlog size too large (or larger than usual)?  
Check contents of binary log using `mysqlbinlog` command and see what the replica is trying to execute. ( `mysqlbinlog --base64-output=decode-rows -vv --start-position=<Exec_Master_Log_Pos> <Relay_Master_Log_File>` )

Ref: [How to Read Simplified SHOW REPLICA STATUS Output](https://www.percona.com/blog/how-to-read-simplified-show-replica-status/)

Thanks,  
K

---

<div class="post-metadata">

**Author:** ![Deniska80](https://avatars.discourse-cdn.com/v4/letter/d/db5fbb/32.png) [@Deniska80](https://forums.percona.com/u/Deniska80)\
**Post date:** [July 3, 2024, 7:55am UTC](https://forums.percona.com/t/strange-seconds-behind-master-behavior/31349/4 "2024-07-03T07:55:42Z")

</div>

> What was the replica executing while you saw the increased \>lag?  
> Not sure, what i understand you clearly. It executes commands from relay-bin.log, what it fetch from master. No other load on this server, it’s dedicated DB. By the way - it’s hard to catch moment, when it’s not null. I just make 10 consecutive calls of ‘show slave status’ in 2 seconds and only once i saw ‘Seconds behind master’ defferent from 0.

> Did you see while your lag was increasing did you have \>exec\_master\_log\_pos moving?  
> Yes, it’s moving allways

> Is the binlog size too large (or larger than usual)?  
> Bin log on master? No, usually size

> see what the replica is trying to execute.  
> looks like it normally executes commands from master, about 500 op/s

One thing, i noted. May be it’s important. At this time this replica has “Master\_Log\_File: mysql-bin.016728”, while master allready has mysql-bin.017213. That’s OK, replica behind master. But at the same time replica has only two relay-bin.xxxx files (as i understand one is some kind of index, and other constantly gowing, while reach max\_binlog\_size). Then this files instantly removes and next two files appears. As i remeber from past, when replica try to reach master, there are a lot of relay-bin.xxxx files, coz fetching binlog is faster, than executes it.

May be that’s the reason? Low network speed?

---

<div class="post-metadata">

**Author:** ![kedarpercona](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/kedarpercona/32/809_2.png) [@kedarpercona](https://forums.percona.com/u/kedarpercona)\
**Post date:** [July 4, 2024, 8:28am UTC](https://forums.percona.com/t/strange-seconds-behind-master-behavior/31349/5 "2024-07-04T08:28:36Z")

</div>

hmmm! 400+ binlogs behind?! Well then I think you surely need to figureout why do we have this case. May be it is low network… not sure if your replication down for long…

---

<div class="post-metadata">

**Author:** ![Deniska80](https://avatars.discourse-cdn.com/v4/letter/d/db5fbb/32.png) [@Deniska80](https://forums.percona.com/u/Deniska80)\
**Post date:** [July 4, 2024, 11:40am UTC](https://forums.percona.com/t/strange-seconds-behind-master-behavior/31349/6 "2024-07-04T11:40:33Z")

</div>

[quote=“kedarpercona, post:5, topic:31349”]  
400+ binlogs behind?!  
my binlog just 100Mb size, so 400 files is just about 8 hours

main question for me is “why sometimes Seconds behind master is 0”. May be it’s 0 in time, while next binlog not fully fetched from master, due to network perfomance… but it’s strange.

---

<div class="post-metadata">

**Author:** ![Deniska80](https://avatars.discourse-cdn.com/v4/letter/d/db5fbb/32.png) [@Deniska80](https://forums.percona.com/u/Deniska80)\
**Post date:** [July 4, 2024, 11:52am UTC](https://forums.percona.com/t/strange-seconds-behind-master-behavior/31349/7 "2024-07-04T11:52:43Z")

</div>

Ok, i iperf network perfomance between this replica and master, results are about 20…40Mbit/s. But speed of growing current relay-bin.log is far slower, it’s transfer one 100Mb file about 1 minute. That’s really strange, i think replica must fetch bin logs on full speed.
