[MDEV-13446] fts_create_doc_id() unnecessarily allocates 8 bytes for every inserted row Created: 2017-08-04 Updated: 2017-10-09 Resolved: 2017-10-09 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB, Storage Engine - XtraDB |
| Affects Version/s: | 10.0, 10.1, 10.1.23, 10.2 |
| Fix Version/s: | 10.0.33, 10.1.29, 10.2.10, 10.3.3 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Armin | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | upstream | ||
| Environment: |
Debian 9, Server version: 10.1.23-MariaDB-9+deb9u1 |
||
| Attachments: |
|
| Sprint: | 10.2.10 |
| Description |
|
After a lot of activity (SELECTs and INSERTS for hours) with 100% CPU load of mysqld, the memory consumption grows and grows.
|
| Comments |
| Comment by Elena Stepanova [ 2017-08-04 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Please attach your cnf file(s). From the description, it seems that you are observing this problem on a regular basis. Is it production? Would you be able to enable the general log for one cycle of restart - memory growth - crash, and then provide it, ideally along with the schema? Do you happen to have the coredump from the crash, and if not, can you get one next time when the problem occurs? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Armin [ 2017-08-07 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I have attached a part of the general log file. This part is one cycle (of more than thousand) which create the error. Yes, it a production system and I can recreate the crash with the mentioned queries each time. It was also possible to trigger the crash using | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2017-08-07 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks for this. Could you please also attach your cnf file(s) and paste the output of SHOW CREATE TABLE for the involved tables? (It might be easier to run mysqldump with for the schema only, without data). When we have this, we can set up a test running the same workflow on artificial data, and hopefully reproduce the problem. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Armin [ 2017-08-19 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I have attached the cnf file I use on a Debian 9 base installation. Also attached is a mysqldump and a php script to reproduce the error. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Alice Sherepa [ 2017-09-18 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Memory leak, reproducible on 10.0, 10.1, 10.2
from top:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2017-10-04 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
alice, I cannot repeat this on 10.0. There were some syntax errors in your SQL snippet, which I may of course have fixed incorrectly. Here is my version of the test:
For me, for both xtradb and innodb_plugin (10.0 debug build), the resident set size is growing slowly, but it is around 120 megabytes. After some 2 minutes of CPU time, the resident set size of xtradb and innodb_plugin (10.1 non-debug build) exceeded 160 megabytes. To rule out a memory leak, I built the executable -DWITH_ASAN and shut down the server (killall -QUIT mysqld) while the test was running. The initial RSS is larger (over 300 megabytes instead of some 100 megabytes) due to ASAN overhead. At 1 minute and 36 seconds of CPU usage it exceeds 400 megabytes. No leaks or other errors were reported by AddressSanitizer. I think that this is a memory fragmentation problem. alice, can you please narrow it down? If the FULLTEXT INDEX are omitted, will it improve? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Alice Sherepa [ 2017-10-06 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Marko Mäkelä, test was correct, but not mtr-friendly, you need semicolon after DELIMITER $$ in mtr, but not if you just use client, as I did.
after 15 min
If there is no FULLTEXT INDEX there, then memory is not growing. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2017-10-06 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
alice, thanks! I did observe a slow growth as well, maybe a few dozen megabytes per minute. But no memory leak. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2017-10-09 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
With pprof from Google pertools, I determined that the culprit is the call to fts_create_doc_id(). It is unnecessarily allocating a new 8-byte buffer for the value of the hidden FTS_DOC_ID column. This buffer could be allocated just once, at the end of row_prebuilt_t::ins_upd_rec_buff. This is not actually memory fragmentation. This is unnecessary allocation of memory when a previous allocation in the same mem_heap_t could be reused. |