MySQLメモリの増加によるデータベースの停止-ソリューション?

4980 ワード

MySQLメモリの増加によるデータベースの停止-ソリューション?
オリジナル
 
2018-03-17
 
徐春陽
データベースエッセイ
      Memory usage gradually increases and brings server to halt.
先日、あるシステムのMySQLデータベースのメモリが漏れている疑いがあることについて言及しました.リンクを参照してください.MySQL 5.7.18以上のバージョンでメモリが漏れている疑いがあることが見つかりました.一部のネットユーザーから5.7.18以上のバージョンを使用しているというフィードバックがあったが、メモリの漏洩が発見された.これらの情報を受け取って、内心の感じは少し言えなくて、自分が運が悪いのか、それともどこが間違っているのか.しばらく追跡し続けたが、mysqlがメモリ割り当てに深刻な異様性を持っていることは発見されず、オペレーティングシステムのいくつかの原因ではないかと疑われている. 
本当に原因が見つからないので、今日はmysqlのbugsシステムで運を試して、何か手がかりを見つけたり、答えを見つけたりします. 
よくひっくり返して、私たちが出会った現象によく似たbugを探しました.
Bug #83047
Memory usage gradually increases and brings server to halt
それをreviewして、もとはこれらの多くの人がこの問題に出会って、愚痴をこぼす小さい心理は少し慰めて、もとは1つのケースではありませんて、間接的に私たち自身と関係がないことを証明しました. 
次は、バグに遭遇した人からのフィードバックです.
  [20 Sep 2016 7:40] Machiel Richards
How to repeat:Install mysql 5.7 and run for about a week or so with medium amount of traffic (mostly write traffic). 

[10 Aug 2017 8:34] Peter Bukaowski
Hello

I am observing the same situation on multiple mysql installations running mysql 5.7.19 on ubuntu server 16.04.

[25 Sep 2017 11:01] Athi Nivas
Hi,

We're facing a similar issue like this while using MySQL 5.7.18 Community edition in our CentOS 7 systems(CentOS Linux release 7.3.1611 (Core), Linux 172.20.19.194 3.10.0-514.26.2.el7.x86_64).

After many concurrent connections to the server, there seems a substantial increase in the amount of memory being used by mysql process & eventually results in OS crash due to memory overflow. Think, the memory allocated for each connection(s) are not set to free properly.

So, we tried using the TCMalloc(http://goog-perftools.sourceforge.net/doc/tcmalloc.html) for memory allocation. We found the memory is under control & everything seems normal after that.

As both innodb_use_sys_malloc and innodb_additional_mem_pool_size were deprecated in MySQL 5.6 and removed in MySQL 5.7. I'm not sure which allocator went awful.

Does this a bug in MySQL innodb memory allocator (or) the system allocation went wrong? Shall we proceed with TCMalloc? I believe MySQL itself recommends it as an optional memory-allocator in its documentation.https://dev.mysql.com/doc/refman/5.7/en/mysqld-safe.html#option_mysqld_safe_malloc-libThanks,
Athi



[20 Nov 2017 13:27] Van Stokes
Ubuntu 16.04.03
MySQL: 5.7.20-log (CE; MySQL apt repo)
Replication: 4xMasters Circular, 6xSlaves
Server type: Dedicated; Non-VM
Server physical RAM: 32GB

We hve the same problem. Excessive memory usage over-time (according to TOP, PS, etc) causing SWAP to be utilized. However, I notice that it happens on my backup/slave servers the most. We backup using "mysqldump" and we dump large databases with a large packet size. We do not have performance schema enabled on the slaves.

And, according to vmstat, we are swapping in/out large number of pages.

--- mysqld.cnf ---

出会った人は本当に多いですね.しかし、最も重要なのは、解決策にも言及しています.
[28 Sep 2017 7:53] Athi Nivas
Hi Bogdan,

Yes. And changing the memory allocator used for memory operations solved the issue. We've tried with TCMalloc as mentioned here ( https://dev.mysql.com/doc/refman/5.7/en/mysqld-safe.html#option_mysqld_safe_malloc-lib ).

Kindly share your thoughts on whether we can proceed with this memory allocator change in our production environment?? is it a safe bet on relying external memory allocator? (or) we should downgrade to a MySQL 5.7 minor version, which doesn't reproduce this issue. 

Much Thanks, 
Athi

[10 Aug 2017 8:45] Machiel Richards
Hi Peter

    I managed to solve this issue for us by enabling a different memory allocation library called jemmalloc. 

    When using the default libraries, the issue comes up, however when enabling jemmalloc libraries,everything became stable again. 

   Steps to follow for this on ubuntu was as follows : 

       - apt-get install libjemalloc1
       - restart mysql service

    You can then use percona toolkit (latest version) to verify that the new memory allocation library is being used. 

    This resolved the issue for me, even though the original bug does not get fixed, but at least a fix to resolve the issues. 

     I have done a whole writeup on the issue for myself, and you are welcome to pm me and I will forward it to you. 

Regards

メモリの割り当て方法を変えたことで解決しましたか?もし本当にそうなら、以前著者はメモリの割り当てと解放の方法を追跡することによって位置決めしたいと思っていましたが、すべての苦労はすべてほほほとしました.現在、上記のシナリオの著者はまだ検証していません.つまり、このソリューションを望んでいます.政府ができるだけ早くバグを修復することを望んでいる. 
      
MySQL 5.7.18以降でメモリ漏洩の疑い
mysql 5で7の上でこのバグを発見して、汚くてたまらないことに注意します
MySQL 5.7.20リリース--MGR機能に関する2つの重要な機能を提供
mysql group relication原理解析
mysql group replication内部動作メカニズム解析
2017データベース大会実録-MySQLコアパラメータの意味のソースコード解析
       
原文のリンクを押して、bugのウェブサイトに行ってこのbugの詳細を見ます.