[MDEV-16234] CREATE TABLE .. SELECT LASTVAL is written to binlog as single statement, causes discrepancy between master and slave Created: 2018-05-21  Updated: 2018-05-24  Resolved: 2018-05-22

Status: Closed
Project: MariaDB Server
Component/s: Replication, Sequences
Affects Version/s: 10.3
Fix Version/s: 10.3.8

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Michael Widenius
Resolution: Fixed Votes: 0
Labels: None


 Description   

--source include/have_innodb.inc
--source include/have_binlog_format_mixed.inc
--source include/master-slave.inc
 
CREATE SEQUENCE s ENGINE=InnoDB;
SELECT NEXTVAL(s);
CREATE TABLE t ENGINE=InnoDB SELECT LASTVAL(s) AS a;
SELECT * FROM t;
--sync_slave_with_master
SELECT * FROM t;
 
# Cleanup
--connection master
DROP TABLE t;
DROP SEQUENCE s;
--source include/rpl_end.inc

In the test case above, CREATE TABLE t ENGINE=InnoDB SELECT LASTVAL(s) AS a is written to the binary log as is, without splitting it into CREATE and a row insert. However, on the slave LASTVAL expectedly returns NULL, hence the table contents between master and slave diverge, which will naturally cause further replication problems.

Actual result

SELECT * FROM t;
a
1
connection slave;
SELECT * FROM t;
a
NULL



 Comments   
Comment by Michael Widenius [ 2018-05-22 ]

Fixed by marking NEXTVAL() and LASTVAL() to be replicated row based

Comment by Michael Widenius [ 2018-05-22 ]

Pushed

Generated at Thu Feb 08 08:27:23 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.