I've had a search through previous questions but can't find an exact match to my question:
At what point during a query transaction is the binary log timestamp set and then written to the binary log?
Context: I have been working with a DB which is using master/slave replication. Quite often the slave will fall behind the master server and I am certain is it simply due to there being a lot of transactions in the binary log that share the same timestamp. When I say a lot I am talking about over 150 timestamps belonging to over 9000 entries in a 1 hour log (plus the rest that returned under 9000 entries). This was found using:
mysqlbinlog bin-log.0001 | grep 'TIMESTAMP' | uniq -c | awk '{if ($1>9000){print $0}} ' | sed -e 's/\/\*\!\*\/;//g' | gawk -F '=' '{cmd="date -d @"$2; cmd | getline d; print $1"="$2"\t("d")"; close(d)}'
So I'm basically trying to workout if the number of transactions sharing a timestamp is a reflection of workload on the master server, and whether these numbers are unusual.
When graphing the Second_behind_master it shows linear growth and then a sudden drop off which seems to suggest the same thing.
MySQL version is 5.6.33.