Skip to content

Commit a5c15f5

Browse files
committed
BUG#27016053: REGRESSION IN BINLOG_LOG_ROW INTRODUCED BY ADD_PKE
Group Replication plugin is a multi or single primary replication solution, on which members do execute transactions optimistically and at commit time they decide, if conflicts happen, which must commit or rollback. The conflict detection is based on the write-sets of each transaction, which is collected along the transaction life when it does a update. During detailed performance analysis it was discovered that there were non-optimized memory allocations and memory copy operations on the write-set extraction. In order to solve the performance regression, the following actions were made: 1) optimize memory allocation; 2) reduce memory copy operations; 3) only collect foreign key write-sets when the current table has foreign keys.
1 parent de58d91 commit a5c15f5

5 files changed

+133
-156
lines changed

mysql-test/suite/rpl/r/rpl_transaction_write_set_extraction.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Note #### Storing MySQL user name or password information in the master info rep
55
[connection master]
66
include/assert.inc [The value for transaction_write_set_extraction must be XXHASH64]
77
CREATE TABLE t1 (a BINARY(1) PRIMARY KEY);
8-
SET @@GLOBAL.DEBUG= @debug_saved;
8+
SET @debug_saved= @@GLOBAL.DEBUG;
99
SET @@GLOBAL.DEBUG= '+d,PKE_assert_single_primary_key_generated_insert';
1010
INSERT INTO t1 VALUES(1);
1111
SET @@GLOBAL.DEBUG= @debug_saved;

mysql-test/suite/rpl/t/rpl_transaction_write_set_extraction.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
--connection master
1919
CREATE TABLE t1 (a BINARY(1) PRIMARY KEY);
20-
SET @@GLOBAL.DEBUG= @debug_saved;
20+
SET @debug_saved= @@GLOBAL.DEBUG;
2121
SET @@GLOBAL.DEBUG= '+d,PKE_assert_single_primary_key_generated_insert';
2222
INSERT INTO t1 VALUES(1);
2323
SET @@GLOBAL.DEBUG= @debug_saved;

sql/handler.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8260,7 +8260,6 @@ int binlog_log_row(TABLE* table,
82608260
{
82618261
if (thd->variables.transaction_write_set_extraction != HASH_ALGORITHM_OFF)
82628262
{
8263-
bitmap_set_all(table->read_set);
82648263
if (before_record && after_record)
82658264
{
82668265
size_t length= table->s->reclength;

sql/rpl_transaction_write_set_ctx.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -43,6 +43,13 @@ Rpl_transaction_write_set_ctx::Rpl_transaction_write_set_ctx():
4343
m_has_missing_keys(false), m_has_related_foreign_keys(false)
4444
{
4545
DBUG_ENTER("Rpl_transaction_write_set_ctx::Rpl_transaction_write_set_ctx");
46+
/*
47+
In order to speed-up small transactions write-set extraction,
48+
we preallocate 12 elements.
49+
12 is a sufficient number to hold write-sets for single
50+
statement transactions, even on tables with foreign keys.
51+
*/
52+
write_set.reserve(12);
4653
DBUG_VOID_RETURN;
4754
}
4855

0 commit comments

Comments
 (0)