Bug #91560 Possible Memory leak bug
Submitted: 6 Jul 2018 5:13 Modified: 25 Oct 2018 7:10
Reporter: Sandeep Sethia (OCA) Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:8.0 OS:CentOS
Assigned to: CPU Architecture:ARM
Tags: Contribution, innodb

[6 Jul 2018 5:13] Sandeep Sethia
Description:
In Mysql currently while doing r/w transactions trx_t objects are allocated by ut_zalloc() in Pool::Pool() which would not call the constructors of the trx_t members. 
So to resolve this , struct TrxFactory already contains call to few of the explicit constructor and destructions of trx_t members. However there is a missing call to constructor and destructor for Readview class 
which is heavily used while doing oltp transactions. This could be a potential memory leak issue if the transactions runs for a longer duration with an increased parallel client threads.

How to repeat:
Code review
[6 Jul 2018 5:14] Sandeep Sethia
Possible memory leak Issue in readview

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: memoryleak.patch (application/octet-stream, text), 667 bytes.

[6 Jul 2018 5:42] MySQL Verification Team
Hello Sandeep Sethia,

Thank you for the report and contribution.

Thanks,
Umesh
[23 Jul 2018 6:45] Sandeep Sethia
Any update?
[25 Oct 2018 7:10] Erlend Dahl
Posted by developer -  Bin X Su

In InnoDB, all read views are in fact managed by MVCC class, including
allocating a new view, or destroy a view. So MVCC is responsible to manage
the memory properly for read views. Thus there is no need to construct and
destroy ReadView in TrxFactory.
 
So I would say this is not a bug, which should not introduce memory leak.
 
BTW, I guess the OCA patch has not been tested ever. Because the patch could
not run after being applied, it will crash the server. Because this is
obviously problematic:
 
@@ -302,6 +302,7 @@ struct TrxFactory {
     trx->lock.table_locks.~lock_pool_t();
 
     trx->hit_list.~hit_list_t();
+    trx->read_view->~ReadView();
   }
 
Before this change, there is already an assertion saying:
ut_ad(trx->read_view == NULL);