[MDEV-12992] MariaDB 10.2.6 leaks memory while executing a trigger Created: 2017-06-05 Updated: 2018-01-18 Resolved: 2017-06-11 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Manipulation - Subquery, Server, Triggers |
| Affects Version/s: | 10.2.6 |
| Fix Version/s: | 10.2.7 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Ivan Korenkov | Assignee: | Igor Babaev |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | regression | ||
| Environment: |
Linux Ubuntu Server 16.04, 14.04 |
||
| Attachments: |
|
||||||||||||||||
| Issue Links: |
|
||||||||||||||||
| Description |
|
После обновления с MariaDB 10.1.24 (все работало идеально) на MariaDB 10.2.6 происходит следующее: Постоянно растет потребление памяти до критического и система вырубает процесс mysql И что-то ужасное количество процессов запускается. |
| Comments |
| Comment by Ivan Korenkov [ 2017-06-05 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Как видно на скрине за 15 минут + 50гб виртуалки | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2017-06-06 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi Ivan, Thanks for the report. Can you say anything about your workflow? Is it DML-only, or is there DDL, and what kind, or are there lots of admin statements? How many connections run at a time? How often do they reconnect? Could you please paste or attach some typical SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST \G outputs? Further, please store the output of SHOW GLOBAL STATUS after you started the server (before the memory started growing), and again when it's already grown close to the edge, before you have to restart the server. Before you restart the server, please send SIGHUP (kill -s SIGHUP <pid>). It should make the server write something to the error log. Please attach the whole error log since server startup and till the end of the session, when you restart it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ivan Korenkov [ 2017-06-06 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
1_1.csv SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ivan Korenkov [ 2017-06-06 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Я на самом основном уже делаю откат на 10.1.24 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ivan Korenkov [ 2017-06-06 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Прирост где-то около 1 000 000 - 3 000 000 записей в сутки, которые раскладываются по 3 таблицам | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2017-06-06 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
DML – data modification language – это INSERT/REPLACE, UPDATE, DELETE, SELECT, LOAD DATA, работа с HANDLER, вызов процедур. В зависимости от того, что происходит на сервере, мы будем пытаться понять, где происходит утечка памяти. Судя по статусу, в основном выполняется DML, много используются InnoDB, триггеры и транзакции; очень много присваиваний переменных (SET), создаются какие-то UDF, но непонятно используются ли; одновременных соединений не очень много, но реконнекты происходят часто. Всё это (хотя и не только это) – потенциальные подозреваемые в утечке. Пожалуйста, сохраните и пришлите error log – желательно с результатом SIGHUP, но если не получится, то хотя бы просто полную сессию сервера от старта и до рестарта. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ivan Korenkov [ 2017-06-06 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Да у меня DML | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ivan Korenkov [ 2017-06-06 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Сейчас на сервер практически нет прихода данных, но началось кеширование, которое строит отчеты по всем пришедшим за предыдущие сутки данным. Роста нет. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2017-06-08 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Simplified test case:
Trigger and subquery from a table appear to be important here. Without the trigger the same query executed the same number of times doesn't cause any memory consumption growth; without the subquery the same trigger also works fine. Not reproducible on 10.1. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2017-06-09 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
igor, this is caused by your commit 82cb35be11:
In particular, by this change:
In this bug, trigger invokes Item_singlerow_subselect::fix_length_and_dec() which invokes subselect_single_select_engine::fix_length_and_dec(), then subselect_engine::set_row() and Item_cache::get_cache(). The latter creates a new Item. And the Item constructor counts all items in the SELECT and HAVING clauses:
With your change thd->lex->current_select->select_n_having_items is increased for every trigger invocation, and st_select_lex::setup_ref_array() will allocate larger and larger arrays every time. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2017-06-11 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The fix for this bug was pushed into the 10.2 tree. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2017-06-20 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
For future reference, stored procedures were also affected (it was also fixed):
Also, there could be a scenario without an obvious subquery in the SELECT list:
Prepared statements which are re-executed multiple times also triggered the same problem:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||