Patching DBD-Pg

Date: Wed, 20 Jun 2007
Author: Daniel Vérité
Applies to: Manitou-Mail, any version

If you're running manitou-mdx along with the 1.49 release of DBD-Pg, which has been the current stable version for a while now, a memory leak happening when fetching BYTEA contents may impact your system.. It is triggered specifically when the manitou-mail inverted word index is enabled (this is the default), since word vectors are stored in bytea columns. Its effect is that the process size of manitou-mdx grows rapidly along with new mail being imported, until it reaches its maximum size and dies. Not nice.

Until the fix makes into the distributions, the work-around is to apply a patch available here on rt.cpan.org or a local copy if you can't log in on rt.cpan.org.

If you happen to use a debian system, here is the sequence of commands to patch your system, assuming the patch mentioned above has been downloaded into /tmp:

A few developer packages are required first:
To be run as root:

# apt-get install dpkg-dev
# apt-get install debhelper
# apt-get install fakeroot
# apt-get install libpq-dev

Patch and rebuild the package (may be done as an unpriviledged user)

$ mkdir temp && cd temp
$ apt-get source libdbd-pg-perl
$ cd libdbd-pg-perl-1.49/
$ patch < /tmp/quote.c.memory_leak_dequote_bytea
$ dpkg-buildpackage -rfakeroot -uc -b
Finally, become root again, and:
# cd temp
# dpkg -i libdbd-pg-perl_1.49-2_i386.deb
That's it!