简体   繁体   中英

mysql 5.6 still records as statement after changing binlog_format to row

I ran "set global binlog_format='ROW'" yesterday afternoon, which was STATEMENT before,

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

but after checking the binlog, still some sqls logged as statement, for example :

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

while others could be logged as 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

it's strange to me, I'm sure the change was done before "160607 23:17:21", but why it's still STATEMENT? the mysql version is 5.6.24.

BTW: the secord sql text is "INSERT INTO record (id,shop_id,create_time) VALUES(6001495,'3','2016-06-07 23:38:17')", but logged as "@3='2016-06-07 23:38:18'", why this happens ,the table def is here

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)

the 1st question is resolved, since binlog_format is reset dynamically, the new value "row" only affects future connections, the established ones still adopt "statement". while the 2nd question still there,for "INSERT INTO record (id,shop_id,create_time) VALUES(6001495,'3','2016-06-07 23:38:17 ')", it will be replayed as "INSERT INTO record (id,shop_id,create_time) VALUES(6001495,'3',' 2016-06-07 23:38:18 ')", which results in inconsistency. When master executed "delete from record where id=6001495", slave just encountered error as can't find the matching record

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM