Bug #71425 MySQL 5.6 memory leak
Submitted: 20 Jan 2014 14:46 Modified: 23 Jan 2014 18:52
Reporter: River wu Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Replication Severity:S1 (Critical)
Version:5.6 OS:Any
Assigned to: CPU Architecture:Any
Tags: repository=table

[20 Jan 2014 14:46] River wu
Description:
When setting relay_log_info_repository=TABLE and master_info_repository=TABLE on slaves, slave will memory leak.

How to repeat:
for replication use :
relay_log_info_repository=table
master_info_repository=table
sync-master-info=1

use sysbench :
#./sysbench  --test=tests/db/oltp.lua  --oltp-tables-count=100  --mysql-socket=/tmp/mysql5660.sock --oltp-test-mode=nontrx --max-time=72000 --max-requests=0 --mysql-user=root --myisam-max-rows=5000000 --oltp-table-size=5000000 --num-threads=10 prepare

#./sysbench  --test=tests/db/oltp.lua  --oltp-tables-count=100  --mysql-socket=/tmp/mysql5660.sock --oltp-test-mode=nontrx --max-time=72000 --max-requests=0 --mysql-user=root --myisam-max-rows=5000000 --oltp-table-size=5000000 --num-threads=10 run

you will see slave memory leak quik.

Suggested fix:
1. fix slave use  relay_log_info_repository=TABLE and master_info_repository=TABLE   memory leak.
2. fix slave use  relay_log_info_repository=file and master_info_repository=file slow than  relay_log_info_repository=TABLE and master_info_repository=TABLE
[21 Jan 2014 0:57] River wu
I think meybe sync-master-info=1 make the slave memory leak.
[23 Jan 2014 18:52] Sveta Smirnova
Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments to the original bug instead.

Thank you for your interest in MySQL.

Duplicate of bug #71197
[4 Jun 2014 7:31] Ivan Stoykov
Hello guys, 

There is a case of MySQL 5.5.17 mysql-5.6.17-linux-glibc2.5-x86_64
based replication, with the following settings:
==================================================
master_info_repository = 'TABLE';
relay_log_info_repository = 'TABLE';
slave_parallel_workers = 0 ;
sync_master_info = 1;
sync_relay_log_info = 1;
==================================================

The slave does not release the memory used, even after the SLAVE SQL thread has been stopped, same with restarting the slave as STOP SLAVE; START SLAVE;
===============================================
mysql> STOP SLAVE SQL_THREAD ;
mysql> SELECT SLEEP(5);
mysql> START SLAVE SQL_THREAD;

-----------memory----------
swpd free inact active
0 352768 5202008 26866196
0 344816 5201664 26867924
0 344196 5201352 26869540
0 341096 5201244 26870676
0 341212 5201256 26871592

0 339476 5202368 26872588 <-- stop
0 338624 5202788 26873560 <-- sleep 1
0 338372 5202700 26874900 <-- sleep 2
0 338372 5202744 26875936 <-- sleep 3
0 336884 5202644 26876816 <-- sleep 4
0 334396 5202644 26878228 <-- sleep 5
0 333528 5202012 26880108
0 333040 5202012 26881236 <-- finish

0 332296 5202820 26882892
0 342420 5203756 26878820
===============================================

The memory usage grow very slowly. not suddenly.

After changing the the master_info_repository and relay_log_info_repository to 'FILE', the memory issue is gone.
[4 Jun 2014 7:33] Ivan Stoykov
I am sorry for the typo bellow: the MySQL is version 5.6.17
> There is a case of MySQL 5.5.17 mysql-5.6.17-linux-glibc2.5-x86_64
[14 Jul 2014 16:32] Sveta Smirnova
Ivan,

thank you for the feedback.

I cannot repeat described behavior using options which you provided and original test case. Please open new bug report and provide repeatable test case there.