Bug #41815 memory leak if mysql_server_prepare is enabled
Submitted: 1 Jan 2009 1:43 Modified: 20 Feb 2013 22:04
Reporter: Masahiro Chiba Email Updates:
Status: Unsupported Impact on me:
None 
Category:Connectors: DBD::mysql ( Perl ) Severity:S3 (Non-critical)
Version:4.010 OS:Linux (Debian GNU/Linux lenny)
Assigned to: CPU Architecture:Any
Tags: Contribution

[1 Jan 2009 1:43] Masahiro Chiba
Description:
DBD::mysql has a memory leak when use "mysql_server_prepare=1".

How to repeat:
use DBI;
my $dbh = DBI->connect('dbi:mysql:mysql_server_prepare=1', 'sandbox', 'sandbox');
my $sth = $dbh->prepare('select 1');
while ( 1 ) {
    $sth->execute;
    $sth->fetch;
}

Suggested fix:
because execute many dbd_describe() maybe.
It seems resolved this problem when use this patch.

--- DBD-mysql-4.010.orig/dbdimp.c       2008-12-29 01:52:26.000000000 +0900
+++ DBD-mysql-4.010/dbdimp.c    2009-01-01 10:26:56.000000000 +0900
@@ -3159,7 +3159,6 @@
       /** Store the result in the current statement handle */
       DBIc_NUM_FIELDS(imp_sth)= mysql_num_fields(imp_sth->result);
       DBIc_ACTIVE_on(imp_sth);
-      imp_sth->done_desc= 0;
       imp_sth->fetch_done= 0;
     }
   }
[23 Jan 2009 9:44] Sveta Smirnova
Thank you for the report.

Verified as described.
[8 Jun 2009 21:28] liz drachnik
Hello Masahiro

In order for us to continue the process of reviewing your contribution to MySQL - We need you to review and sign the Sun|MySQL contributor agreement (the "SCA")

The process is explained here: 
http://forge.mysql.com/wiki/Sun_Contributor_Agreement

Getting a signed/approved SCA on file will help us facilitate your contribution-- this one, and others in the future.

Thank you ! 

Liz Drachnik  - Program Manager - MySQL
[2 Oct 2009 23:01] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[4 Nov 2009 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[8 Jun 2010 19:05] Becca Turner
I can confirm this as still broken.

You need to fix this even if you can't get a sign off on that one line change.  Or at least document it as a known memory leak that you can't fix due to bureaucratic deadlock.
[31 Aug 2012 13:54] Serge Konovalov
Almost 4 years, version 4.022 and bug still there.
It makes "server prepare" feature absolutely unusable on high-load web-projects, because scripts consume RAM very quickly.

FreeBSD 8.1-RELEASE amd64
MySQL: 5.1.48 FreeBSD port
DBI 1.622
DBD::mysql 4.022
[20 Feb 2013 22:04] Sveta Smirnova
Thank you for the report.

We don't work on DBD::mysql bugs anymore. All its bugs should go to CPAN: https://rt.cpan.org/Public/Dist/Display.html?Name=DBD-mysql

I re-submitted your report to https://rt.cpan.org/Public/Bug/Display.html?id=83486
Please subscribe to the new report on CPAN and work with DBD::mysql developers in case if they need additional details.