When binlog_row_image=MINIMAL, UPDATE_ROWS_EVENT may change columns that are not in the before image. Such columns had their bit set in table->write_set, but was missing their bit in table->read_set.
As part of this patch, bitmap_union() is extended to handle bitmaps of different sizes, similar to bitmap_intersect(). Signed-off-by: Kristian Nielsen <[email protected]> --- .../rpl/r/rpl_row_minimal_mdev31678.result | 17 ++++++++++++++ .../rpl/t/rpl_row_minimal_mdev31678.test | 23 +++++++++++++++++++ mysys/my_bitmap.c | 11 ++++++--- sql/log_event_server.cc | 8 ++++--- 4 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 mysql-test/suite/rpl/r/rpl_row_minimal_mdev31678.result create mode 100644 mysql-test/suite/rpl/t/rpl_row_minimal_mdev31678.test diff --git a/mysql-test/suite/rpl/r/rpl_row_minimal_mdev31678.result b/mysql-test/suite/rpl/r/rpl_row_minimal_mdev31678.result new file mode 100644 index 00000000000..ff3c55c1fd9 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_row_minimal_mdev31678.result @@ -0,0 +1,17 @@ +include/master-slave.inc +[connection master] +connection slave; +SET @old_format= @@GLOBAL.binlog_row_image; +SET GLOBAL binlog_row_image=MINIMAL; +include/stop_slave.inc +include/start_slave.inc +SET GLOBAL binlog_row_image= @old_format; +connection default; +SET SESSION binlog_row_image=MINIMAL; +CREATE TABLE t (id INT AUTO_INCREMENT, col_int BIGINT NOT NULL, UNIQUE (col_int), KEY(id)) ENGINE=InnoDB; +INSERT INTO t VALUES (1,1); +UPDATE t SET id = 2; +connection slave; +connection master; +DROP TABLE t; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_row_minimal_mdev31678.test b/mysql-test/suite/rpl/t/rpl_row_minimal_mdev31678.test new file mode 100644 index 00000000000..460b22c64fc --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_row_minimal_mdev31678.test @@ -0,0 +1,23 @@ +--source include/have_innodb.inc +--source include/have_binlog_format_row.inc +--source include/master-slave.inc + +--connection slave +SET @old_format= @@GLOBAL.binlog_row_image; +SET GLOBAL binlog_row_image=MINIMAL; +--source include/stop_slave.inc +--source include/start_slave.inc +SET GLOBAL binlog_row_image= @old_format; +--connection default +SET SESSION binlog_row_image=MINIMAL; + +CREATE TABLE t (id INT AUTO_INCREMENT, col_int BIGINT NOT NULL, UNIQUE (col_int), KEY(id)) ENGINE=InnoDB; +INSERT INTO t VALUES (1,1); +UPDATE t SET id = 2; + +--sync_slave_with_master + +# Cleanup +--connection master +DROP TABLE t; +--source include/rpl_end.inc diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c index 68747f57702..c96e6a1ca51 100644 --- a/mysys/my_bitmap.c +++ b/mysys/my_bitmap.c @@ -538,11 +538,16 @@ void bitmap_subtract(MY_BITMAP *map, const MY_BITMAP *map2) void bitmap_union(MY_BITMAP *map, const MY_BITMAP *map2) { - my_bitmap_map *to= map->bitmap, *from= map2->bitmap, *end= map->last_word_ptr; - DBUG_ASSERT_IDENTICAL_BITMAPS(map,map2); + my_bitmap_map *to= map->bitmap, *from= map2->bitmap, *end; + uint len= no_words_in_map(map), len2= no_words_in_map(map2); + uint32 num_bits= MY_MIN(map->n_bits, map2->n_bits); + DBUG_ASSERT_DIFFERENT_BITMAPS(map,map2); - while (to <= end) + end= to + MY_MIN(len, len2) - 1; + + while (to < end) *to++ |= *from++; + *to|= *from & ~last_bit_mask(num_bits); /* Omit last not relevant bits */ } diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc index acef173716a..2152dd24aa8 100644 --- a/sql/log_event_server.cc +++ b/sql/log_event_server.cc @@ -8543,9 +8543,11 @@ Update_rows_log_event::do_exec_row(rpl_group_info *rgi) #endif /* WSREP_PROC_INFO */ thd_proc_info(thd, message); - // Temporary fix to find out why it fails [/Matz] - memcpy(m_table->read_set->bitmap, m_cols.bitmap, (m_table->read_set->n_bits + 7) / 8); - memcpy(m_table->write_set->bitmap, m_cols_ai.bitmap, (m_table->write_set->n_bits + 7) / 8); + /* Must read also after-image columns to be able to update them. */ + bitmap_copy(m_table->read_set, &m_cols); + bitmap_union(m_table->read_set, &m_cols_ai); + /* Must update after-image columns. */ + bitmap_copy(m_table->write_set, &m_cols_ai); m_table->mark_columns_per_binlog_row_image(); -- 2.47.2 _______________________________________________ commits mailing list -- [email protected] To unsubscribe send an email to [email protected]
