Skip Menu |

This queue is for tickets about the DBD-Pg CPAN distribution.

Report information
The Basics
Id: 95505
Status: resolved
Priority: 0/
Queue: DBD-Pg

People
Owner: greg [...] turnstep.com
Requestors: a.solovey [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 3.2.1



Subject: Memory leak with AutoInactiveDestroy
Date: Fri, 09 May 2014 11:08:15 -0500
To: bug-DBD-Pg [...] rt.cpan.org
From: Alex Solovey <a.solovey [...] gmail.com>
Setting AutoInactiveDestroy => 1 on database handle causes serious memory leaks. See attached script for a small example. The support for AutoInactiveDestroy was introduced in 3.0.0 (see bug #68893), but it prevents all statement handles from being destroyed in parent process, instead of those remaining active in a child process after a fork. I do not see any checks for pid change in AutoInactiveDestroy code in DBD::Pg dbdimp.c, while relevant code in DBI has it (DBI.xs): if (DBIc_AIADESTROY(imp_xxh)) { /* wants ineffective destroy after fork */ if ((U32)PerlProc_getpid() != _imp2com(imp_xxh, std.pid)) DBIc_set(imp_xxh, DBIcf_IADESTROY, 1); } Version info: # perl -MDBD::Pg -E 'say DBD::Pg->VERSION' 3.1.1 # perl -MDBI -E 'say DBI->VERSION' 1.63 # uname -a Linux localhost 3.13.10-200.fc20.x86_64 #1 SMP Mon Apr 14 20:34:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux # perl -v This is perl 5, version 18, subversion 2 (v5.18.2) built for x86_64-linux-thread-multi

Message body is not shown because sender requested not to inline it.

RT-Send-CC: DDICK [...] cpan.org
Do not have the tuits to understand this at the moment, cc'ing the original author of this feature.
On Tue May 20 01:48:00 2014, TURNSTEP wrote: Show quoted text
> Do not have the tuits to understand this at the moment, cc'ing the > original author of this feature.
Yup, i missed this. I've attached a small patch that passes the dbd_pg_leak program. Can someone else confirm this patch fixes the issue?
Subject: dbd_pg_leak_fix.patch
diff -Naur old/dbdimp.c new/dbdimp.c --- old/dbdimp.c 2014-05-09 07:52:48.000000000 +1000 +++ new/dbdimp.c 2014-05-20 19:35:14.031328278 +1000 @@ -3833,7 +3833,7 @@ croak("dbd_st_destroy called twice!"); /* If the AutoInactiveDestroy flag has been set, we go no further */ - if (DBIc_AIADESTROY(imp_dbh)) { + if ((DBIc_AIADESTROY(imp_dbh)) && ((U32)PerlProc_getpid() != imp_dbh->pid_number)) { if (TRACE4_slow) { TRC(DBILOGFP, "%sskipping sth destroy due to AutoInactiveDestroy\n", THEADER_slow); }
Show quoted text
> Yup, i missed this. I've attached a small patch that passes the > dbd_pg_leak program. Can someone else confirm this patch fixes the > issue?
Thank you to both of you. I confirmed that the patch fixes the test script, which now reports 0 bytes. Committed with b3e1b403d0b56302b0328342b4fc5275699f1186