[MDEV-26712] row events never reset thd->mem_root Created: 2021-09-28 Updated: 2021-10-27 Resolved: 2021-10-13 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Replication |
| Affects Version/s: | 10.2, 10.3, 10.4, 10.5, 10.6 |
| Fix Version/s: | 10.2.41, 10.3.32, 10.4.22, 10.5.13, 10.6.5 |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Sergei Golubchik | Assignee: | Andrei Elkin |
| Resolution: | Fixed | Votes: | 2 |
| Labels: | Memory_leak, not-10.7 | ||
| Issue Links: |
|
||||||||||||
| Description |
|
row event execution starts from Rows_log_event::do_apply_event which calls open_and_lock_tables() which calls lock_tables(), which does
thus allocating an array of points of the thd's memroot. This is just few bytes, 8 in the test below. But this memory is never freed, not by row events at least. So, by creating a transaction with a huge number of row events we can consume any amount of memory.
To fix that, rbr events must do
somewhere. Where it's safe, because it'll destroy anything allocated on the thd memroot.
|
| Comments |
| Comment by Sergei Golubchik [ 2021-09-28 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrei Elkin [ 2021-09-29 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
To complete the description, the THD::mem_root of the slave applier gets finally released after commit. More precisely at the end of the following Gtid_log_event. | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Roel Van de Paar [ 2021-09-29 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Confirmed. Memory starts increasing on the slave after the commit on the master:
And slave error log mysql-test/var/log/mysqld.2.err shows:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Roel Van de Paar [ 2021-09-29 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Bug also present in 10.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Roel Van de Paar [ 2021-09-29 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Bug now confirmed in 10.2 to 10.6. (To execute on 10.2 use ./mtr --suite=main test after placing test into mysql-test/t/test.test).
10.4-10.5: ref comments above.
10.7 However is not affected (tested twice):
Additionally, the 10.7 test succeeds
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrei Elkin [ 2021-09-29 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Sergei, as you started on it anyway, could you please review as well? | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2021-10-01 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
ddf10294831 looks ok to me | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrei Elkin [ 2021-10-13 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
For merging 10.2->10.3 and 10.4->10.5 conflicts are resolved in
|