将binlog_format更改为row后,mysql 5.6仍然记录为语句

时间:2016-06-08 02:53:36

标签: mysql

我跑了"设置全局binlog_format =' ROW'"昨天下午,这是之前的声明,

root@3306 (none)> show variables like '%format%';
+--------------------------+-------------------+
| Variable_name            | Value             |
+--------------------------+-------------------+
| binlog_format            | ROW               |

但是在检查了binlog之后,仍有一些sqls被记录为语句,例如:

BEGIN
/*!*/;
# at 41498921
#160607 23:17:21 server id 1637  end_log_pos 41499120 CRC32 0xd701f3e2  Query   thread_id=1229089   exec_time=0 error_code=0
SET TIMESTAMP=1465312641/*!*/;
**INSERT INTO RECORD (id,shop_id,create_time) VALUES(6014464753,'3','2016-06-07 23:17:21')**
/*!*/;
# at 41499120
#160607 23:17:21 server id 1637  end_log_pos 41499273 CRC32 0xd1840cf1  Query   thread_id=1229089   exec_time=0 error_code=0
SET TIMESTAMP=1465312641/*!*/;
UPDATE log SET diamond = diamond + 400 WHERE id = 6014464753
/*!*/;
# at 41499273

而其他人可以记录为ROW,

 # at 77950217
#160607 23:38:17 server id 1637  end_log_pos 77950184 CRC32 0x0b0f7620  Rows_query
# **INSERT INTO record (id,shop_id,create_time) VALUES(6001495,'3','*2016-06-07 23:38:17*')**
# at 77950347
#160607 23:38:17 server id 1637  end_log_pos 77950259 CRC32 0x290541ab  Table_map: `test`.`record` mapped to number 1140
# at 77950422
#160607 23:38:17 server id 1637  end_log_pos 77950306 CRC32 0x06774669  Write_rows: table id 1140 flags: STMT_END_F
### INSERT INTO `test`.`record`
### SET
###   @1=6001495 /* INT meta=0 nullable=0 is_null=0 */
###   @2='3' /* VARSTRING(96) meta=96 nullable=0 is_null=0 */
###   @3='*2016-06-07 23:38:18*' /* DATETIME(0) meta=0 nullable=0 is_null=0 */
# at 77950469
对我来说这很奇怪,我确定改变是在" 160607 23:17:21"之前完成的,但为什么它仍然是陈述? mysql版本是5.6.24。

顺便说一句: secord sql文本是" INSERT INTO记录(id,shop_id,create_time)VALUES(6001495,' 3',' 2016-06-07 23:38:17') ",但记录了 as" @ 3 =' 2016-06-07 23:38:18'",为什么会发生这种情况,表def就在这里

Create Table: CREATE TABLE `record` (
  `id` int(11) unsigned zerofill NOT NULL,
  `shop_id` varchar(32) NOT NULL,
  `create_time` datetime NOT NULL,
  KEY `id` (`id`),
  CONSTRAINT `rech_gif` FOREIGN KEY (`id`) REFERENCES `info` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)

1 个答案:

答案 0 :(得分:0)

第一个问题得到解决,因为binlog_format是动态重置的,新值“row”只影响未来的连接,已建立的连接仍然采用“语句”。 而第二个问题仍然存在,因为“INSERT INTO record(id,shop_id,create_time)VALUES(6001495,'3','2016-06-07 23:38:17 ')”,它将被重播为“INSERT INTO record(id,shop_id,create_time)VALUES(6001495,'3',' 2016-06-07 23:38:18 ')”,这会导致不一致。当master执行“从id = 6001495的记录中删除”时,slave刚遇到错误,因为找不到匹配的记录