mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
BUG#41986 Replication slave does not pick up proper AUTO_INCREMENT value for Innodb tables
The next number (AUTO_INCREMENT) field of the table for write rows events are not initialized, and cause some engines (innodb) not correctly update the tables's auto_increment value. This patch fixed this problem by honor next number fields if present. mysql-test/extra/rpl_tests/rpl_auto_increment.test: Add test code for BUG#41986 mysql-test/suite/rpl/r/rpl_auto_increment.result: update test result file for BUG#41986 sql/log_event.cc: set next_number_field before writing rows, and reset next_number_field after finished writing rows
This commit is contained in:
@ -145,6 +145,23 @@ select * from t3 order by a;
|
||||
connection master;
|
||||
|
||||
drop table t1,t2,t3;
|
||||
sync_slave_with_master;
|
||||
|
||||
#
|
||||
# BUG#41986 Replication slave does not pick up proper AUTO_INCREMENT value for Innodb tables
|
||||
#
|
||||
connection master;
|
||||
set auto_increment_increment=1;
|
||||
set auto_increment_offset=1;
|
||||
CREATE TABLE t1 (id MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE=innodb;
|
||||
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
|
||||
show create table t1;
|
||||
|
||||
sync_slave_with_master;
|
||||
show create table t1;
|
||||
|
||||
connection master;
|
||||
drop table t1;
|
||||
|
||||
# End cleanup
|
||||
sync_slave_with_master;
|
||||
|
@ -227,3 +227,20 @@ select * from t3 order by a;
|
||||
a
|
||||
127
|
||||
drop table t1,t2,t3;
|
||||
set auto_increment_increment=1;
|
||||
set auto_increment_offset=1;
|
||||
CREATE TABLE t1 (id MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE=innodb;
|
||||
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`id` mediumint(9) NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`id` mediumint(9) NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
|
@ -8091,6 +8091,9 @@ Write_rows_log_event::do_before_row_operations(const Slave_reporting_capability
|
||||
analyze if explicit data is provided for slave's TIMESTAMP columns).
|
||||
*/
|
||||
m_table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
|
||||
|
||||
/* Honor next number column if present */
|
||||
m_table->next_number_field= m_table->found_next_number_field;
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -8099,6 +8102,7 @@ Write_rows_log_event::do_after_row_operations(const Slave_reporting_capability *
|
||||
int error)
|
||||
{
|
||||
int local_error= 0;
|
||||
m_table->next_number_field=0;
|
||||
if (bit_is_set(slave_exec_mode, SLAVE_EXEC_MODE_IDEMPOTENT) == 1 ||
|
||||
m_table->s->db_type()->db_type == DB_TYPE_NDBCLUSTER)
|
||||
{
|
||||
|
Reference in New Issue
Block a user