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.
I’m getting this alert in my mysql-error.log file that, can you please suggest what action i have to take.
2015-11-03 00:00:02 4378 [Warning] Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. The statement is unsafe because it uses a LIMIT clause. This is unsafe because the set of rows included cannot be predicted. Statement: UPDATE city SET city.active_day = ‘2015-11-03 00:00:00’ WHERE city.code = ‘DELHI’ AND city.active_day IS NULL LIMIT 150.
Hi Scott, after addition of order by also i’m getting the error. Please advise, it is necessary to change the binary format to MIXED.
2015-11-06 00:00:24