Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT., mysqlbinlog

Source: Internet
Author: User

Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT., mysqlbinlog
I. Problem Description014-12-15 20:00:29 4398 [Warning] Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... on duplicate key update on a table with more than one unique key is unsafe Statement: insert into 'longxibendi '('lxid', 'l _ id', 'l _ aplply ', 'l _ types', 'mes mes ') VALUES (75692,218, 8, 2, 1418644829) on duplicate key update 'mes mes' = 1418644829
An error is reported in the err log of a mysql master.
Ii. CauseCheck the cause. The longxibendi table has two unique keys. INSERT... on duplicate key update is used, and the current database binlog_format is in statement format. This SQL statement will report "unsafe.
Check the manual

  • INSERT... on duplicate key update statements on tables with multiple primary or unique keys. when executed against a table that contains more than one primary or unique key, this statement is considered unsafe, being sensitive to the order in which the storage engine checks the keys, which is not deterministic, and on which the choice of rows updated by the MySQL Server depends.

    AnINSERT ... ON DUPLICATE KEY UPDATEStatement against a table having more than one unique or primary key is marked as unsafe for statement-based replication beginning with MySQL 5.6.6. (Bug #11765650, Bug #58637)

Http://dev.mysql.com/doc/refman/5.6/en/replication-rbr-safe-unsafe.html

According to the official explanation, the server layer transmits data to the innodb engine. The innodb engine checks that the key value is sensitive.
In my personal understanding, it may be related to the fact that the server and innodb only transmit one row of data at a time.
Iii. Problem SolvingTwo methods: 1. Modify binlog_format to mixed; log on to mysql and run set global binlog_format = MIXED; 2. Do not use this type of SQL;
Note the following 1st methods. For the database architecture of the master-> slave structure. Log_slave_updates is enabled on the slave. After modifying the binlog format on the master node, the slave database of log_slave_updates is enabled, and the slave database of log_slave_updates is released. Therefore, you must first set binlog_format = mixed on the slave and then set it on the master. Slave error message: Last_ SQL _Errno: 1666
Last_ SQL _Error: Error executing row event: 'cannot execute statement: impossible to write to binary log since statement is in row format and BINLOG_FORMAT = STATEMENT .'


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.