I am not sure when and how did this happen, But i just happen do view my log file files and i was surprised to see it throwing up this errors continuously like this :-
As i am not sure what this is and what it means, I am seeking your kind and humble support.
I would also like to point out that my server was rebooted 48 hrs ago, could this be the reason for the same ?
I also have a replication server setup and it seems to be functioning normally.
The error message it gives you is pretty good actually. Basically the statement that it is warning you about could potentially end up with different results when it runs on the slave versus when it ran on the master. This is something that a tool like Percona’s pt-table-checksum (see below link) can help with to detect what is called slave drift or data drift, which is when the slave has different data than the master.
What to actually do about this (other than check your tables with the tool I mentioned) depends on the situation. The query it is warning you about may end up working perfectly fine, but you would not know for sure without checking, and even then it may work sometimes and not others.
The best option in my opinion is to switch to row based replication to avoid this, as then MySQL is replicating the data itself and not the statement. Row based replication has some downsides, mainly that more data is transferred, so slave lag may be more of an issue in extreme cases, so you’ll want to read up on that first before making any changes.
The other option would be to re-write the query to avoid any functions / formatting that results in unsafe queries for statement best replication (see below link).
Firstly accept my appreciation for looking into my thread and paying heed to it.
Secondly to just switch to “ROW” based replication, I can see that all i need to do is specify the command globally for all.
like this :- mysql> SET GLOBAL binlog_format = ‘ROW’;
** NOTE :- i guess this can be done on the fly without any restart, am i correct ?
Further, I was also going further through the doc link that you have provided with regards to ROW based replication and i could also see it ALSO mentions about “Mixed replication (statement and row based replication)”. Could you suggest if this is also a viable option ? :-
Mixed format does pretty much what it sounds like, but I’ve never used it myself and have not seen many other people using it. So that choice is up to you, but I would make sure to research / test it first.
The binlog_format variable is dynamic, so you may change it at any point. The cleanest way would be to set it in your my.cnf on the master and restart the server, otherwise you can stop replication on your slave, change the setting dynamically on the master, and then start replication on your slave so that it picks up the change since a change in global variables only applies to new connections.
I’m sorry about those replies being lost.
I can now only add that the MIXED mode is a good compromise between statement and ROW, and will work for the statement you had in warning message. Basically, for any data update that is “unsafe” from replication point of view, MySQL will log all changed rows values instead of the original statement. But it will keep logging other updates the same way as in statement mode.
I have gone ahead and used the mixed mode replication and it has been more than 6 hours and both the servers seem to be doing fine with NO errors being reported et all on the Master Server.
Thanks to you and przemek, i find this issue to be resolved.
Nice work! Just make sure to check for slave drift occasionally using a tool like pt-table-checksum since you are still using statement based replication with the mixed format.
You mean to say “statement based replication” should NOT be used with mixed mode replication or NOT be used et all, Instead always use “row based replication”, is this more safer and should this be preferred over “statement” ?
Can you please clarify this,
I think i am doing a merry-go-round here :D, apologies for that!!
In “MIXED” mode, replicated transactions are written in either of two formats: row based logging, or statement based login. MySQL decides to use statement or row based log entry if it considers a given statement is “safe” or not. So “safe” updates will be logged just like in the STATEMENT binlog format, and “not-safe” will be logged as row-based events. This way the MIXED mode is more safe then STATEMENT from data integrity point of view. It’s just a compromise between pure STATEMENT or pure ROW modes.
Now, whether to use pure ROW format, we can argue, as there are many pros and cons of this solution, take a look here:
[url]http://dev.mysql.com/doc/refman/5.5/en/replication-sbr-rbr.html[/url]
The fact is, that starting from MySQL 5.6, ROW based replication works much better then in previous versions.
A bit off topic I guess, but I wonder, why does pt-table-checksum requires STATEMENT based binlog? It fills up my MySQL error log with warnings about unsafe statements…
It’s quite simple, in order to calculate checksum numbers for data in order to later compare them between master and slave, those calculations have to be done separately on master and slave. With ROW binary format, the slave is only applying row changes from master, so the checksum table would be the same. Yet we need statements replicated to slaves, not data. But that’s just per pt-table-checksum session setting, all the rest traffic goes via globally set binlog format.
Just to be clear, pt-table-checksum is setting its SESSION level binlog_format to STATEMENT and not GLOBAL? I noticed that the global setting is still MIXED when running “SHOW GLOBAL VARIABLES LIKE ‘binlog_format’;” while pt-table-checksum is running “nohup pt-table-checksum --no-check-binlog-format --empty-replicate-table > /dev/null 2>&1 &”
Why is this? Is this explained in more detail somewhere? What is the issue exactly? Because filling up the log with these warnings doesn’t seem like correct behaviour.
Well I understand what you are saying Przemek. I understand that it has to replicate the statements to the slaves, in order to re-run them there, and not the data. That is fine. But why it doesn’t run when you have a MIXED binlog_format on the master and the slaves? It is asking me to put the –no-check-binlog-format option on pt-table-checksum script. When I put the options it does run and does checksum both server and slaves which are in MIXED mode. But unfortunately it requires that the user has the SUPER privilege. Because it needs that to set the binlog_format to STATEMENT at run time. Is this really necessary?
@przemek, how mysql 5.6 handles or decide whether the statement is safe or unsafe for replication when GTID is enabled and of course GTID requires ROW bin log format enabled.