-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BUG#34819861: Gtid_set::Interval_chunk mem incorrectly tracked on THD…
…_applier_module_receiver In a GR cluster setup with a primary and two secondaries, it was observed that the primary was not releasing all allocated memory related to the "memory/sql/Gtid_set::Interval_chunk" event name. The memory used by GR associated to the the key `memory/sql/Gtid_set::Interval_chunk` is allocated by one thread: `thread/group_rpl/THD_applier_module_receiver`, but it is released by a different thread: `thread/group_rpl/THD_certifier_broadcast`. This was causing a incorrect memory usage relative to `thread/group_rpl/THD_applier_module_receiver` since only memory allocations were accounted, making the reported memory always increasing. The global memory reported on performance_schema.memory_summary_global_by_event_name` was not affected. In order to avoid the incorrect memory usage, the used memory ownership is transferred from `thread/group_rpl/THD_applier_module_receiver` when it becomes out of scope into `thread/group_rpl/THD_certifier_broadcast` when it becomes part of the scope. Change-Id: Ieda9c40b52a42f75636004d590440674b2665af9
- Loading branch information
1 parent
4e4ef1d
commit a96fd3c
Showing
6 changed files
with
206 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
mysql-test/suite/group_replication/r/gr_internal_chunk_memory_release.result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
include/group_replication.inc | ||
Warnings: | ||
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. | ||
Note #### Storing MySQL user name or password information in the connection metadata repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START REPLICA; see the 'START REPLICA Syntax' in the MySQL Manual for more information. | ||
[connection server1] | ||
include/start_and_bootstrap_group_replication.inc | ||
|
||
############################################################ | ||
# 1. Populate server with data to alloc memory using | ||
# Gtid_set::Interval_chunk key. | ||
CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, c2 INT) ENGINE=InnoDB; | ||
BEGIN; | ||
INSERT INTO t1 (c2) values (2); | ||
INSERT INTO t1 (c2) values (2); | ||
INSERT INTO t1 (c2) values (2); | ||
INSERT INTO t1 (c2) values (2); | ||
INSERT INTO t1 (c2) values (2); | ||
COMMIT; | ||
|
||
############################################################ | ||
# 2. Assert values on thread and global counters before | ||
# running garbage collect. | ||
include/assert.inc [Global counters shall been higher than sum of applier and certifier threads.] | ||
|
||
############################################################ | ||
# 3. Wait for execution of another garbage collection | ||
|
||
############################################################ | ||
# 4. Assert values on thread and global counters after | ||
# running garbage collect. | ||
include/assert.inc [Global counters shall been higher than sum of applier and certifier threads.] | ||
|
||
############################################################ | ||
# 5. Cleanup | ||
DROP TABLE t1; | ||
include/group_replication_end.inc |
89 changes: 89 additions & 0 deletions
89
mysql-test/suite/group_replication/t/gr_internal_chunk_memory_release.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
################################################################################ | ||
# Validate that primary releases all allocated memory related to | ||
# "memory/sql/Gtid_set::Interval_chunk" event name. | ||
# | ||
# Test: | ||
# 0. The test requires one server: M1. | ||
# 1. Populate server with data to alloc memory using | ||
# Gtid_set::Interval_chunk key. | ||
# 2. Assert values on thread and global counters before | ||
# running garbage collect. | ||
# 3. Wait for execution of another garbage collection | ||
# 4. Assert values on thread and global counters after | ||
# running garbage collect. | ||
# 5. Cleanup | ||
################################################################################ | ||
|
||
--source include/have_nodebug.inc | ||
--source include/not_valgrind.inc | ||
--source include/not_asan.inc | ||
--source include/big_test.inc | ||
--source include/have_group_replication_plugin.inc | ||
--let $rpl_skip_group_replication_start= 1 | ||
--source include/group_replication.inc | ||
|
||
--source include/start_and_bootstrap_group_replication.inc | ||
|
||
|
||
--echo | ||
--echo ############################################################ | ||
--echo # 1. Populate server with data to alloc memory using | ||
--echo # Gtid_set::Interval_chunk key. | ||
|
||
CREATE TABLE t1 (c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, c2 INT) ENGINE=InnoDB; | ||
|
||
BEGIN; | ||
INSERT INTO t1 (c2) values (2); | ||
INSERT INTO t1 (c2) values (2); | ||
INSERT INTO t1 (c2) values (2); | ||
INSERT INTO t1 (c2) values (2); | ||
INSERT INTO t1 (c2) values (2); | ||
COMMIT; | ||
|
||
--exec $MYSQL_SLAP --create-schema=test --delimiter=";" --iterations=100 --query="INSERT INTO t1 (c2) SELECT c2 FROM t1 LIMIT 5" --concurrency=1 --silent | ||
|
||
|
||
--echo | ||
--echo ############################################################ | ||
--echo # 2. Assert values on thread and global counters before | ||
--echo # running garbage collect. | ||
|
||
--let $applier_bytes_used= `SELECT CURRENT_NUMBER_OF_BYTES_USED FROM performance_schema.memory_summary_by_thread_by_event_name JOIN performance_schema.threads USING(thread_id) WHERE event_name = "memory/sql/Gtid_set::Interval_chunk" AND name = "thread/group_rpl/THD_applier_module_receiver"` | ||
--let $certifier_bytes_used= `SELECT CURRENT_NUMBER_OF_BYTES_USED FROM performance_schema.memory_summary_by_thread_by_event_name JOIN performance_schema.threads USING(thread_id) WHERE event_name = "memory/sql/Gtid_set::Interval_chunk" AND name = "thread/group_rpl/THD_certifier_broadcast"` | ||
--let $global_bytes_used= `SELECT CURRENT_NUMBER_OF_BYTES_USED FROM performance_schema.memory_summary_global_by_event_name WHERE EVENT_NAME = "memory/sql/Gtid_set::Interval_chunk"` | ||
|
||
--let $assert_text= Global counters shall been higher than sum of applier and certifier threads. | ||
--let $assert_cond= [SELECT $applier_bytes_used + $certifier_bytes_used] <= $global_bytes_used | ||
--source include/assert.inc | ||
|
||
|
||
--echo | ||
--echo ############################################################ | ||
--echo # 3. Wait for execution of another garbage collection | ||
|
||
--let $wait_timeout= 150 | ||
--let $wait_condition= SELECT Count_transactions_rows_validating=5 FROM performance_schema.replication_group_member_stats WHERE member_id IN (SELECT @@server_uuid) | ||
--source include/wait_condition.inc | ||
|
||
|
||
--echo | ||
--echo ############################################################ | ||
--echo # 4. Assert values on thread and global counters after | ||
--echo # running garbage collect. | ||
|
||
--let $applier_bytes_used= `SELECT CURRENT_NUMBER_OF_BYTES_USED FROM performance_schema.memory_summary_by_thread_by_event_name JOIN performance_schema.threads USING(thread_id) WHERE event_name = "memory/sql/Gtid_set::Interval_chunk" AND name = "thread/group_rpl/THD_applier_module_receiver"` | ||
--let $certifier_bytes_used= `SELECT CURRENT_NUMBER_OF_BYTES_USED FROM performance_schema.memory_summary_by_thread_by_event_name JOIN performance_schema.threads USING(thread_id) WHERE event_name = "memory/sql/Gtid_set::Interval_chunk" AND name = "thread/group_rpl/THD_certifier_broadcast"` | ||
--let $global_bytes_used= `SELECT CURRENT_NUMBER_OF_BYTES_USED FROM performance_schema.memory_summary_global_by_event_name WHERE EVENT_NAME = "memory/sql/Gtid_set::Interval_chunk"` | ||
|
||
--let $assert_text= Global counters shall been higher than sum of applier and certifier threads. | ||
--let $assert_cond= [SELECT $applier_bytes_used + $certifier_bytes_used] <= $global_bytes_used | ||
--source include/assert.inc | ||
|
||
|
||
--echo | ||
--echo ############################################################ | ||
--echo # 5. Cleanup | ||
|
||
DROP TABLE t1; | ||
|
||
--source include/group_replication_end.inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters