Your message dated Tue, 02 Jul 2019 12:48:31 +0000
with message-id <[email protected]>
and subject line Bug#930728: fixed in postgresql-common 202
has caused the Debian Bug report #930728,
regarding pg_cltlcluster leaks logfile descriptor into PostgreSQL backends
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
930728: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=930728
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: postgresql-common
Version: 199

When I execute
service postgresql start
I observe that logfile descriptor will leak into postmaster and every backend. 
This is not fd opened by PG's syslogger.

root@rc1b-tl7je3ulcm4z9v3c ~ # lsof | grep 'postgresql-10-data.log' | grep 
postgres | grep '/var/log'
postgres  289999          postgres    4w      REG              253,1 103172283  
   131900 /var/log/postgresql/postgresql-10-data.log
postgres  290011          postgres    1w      REG              253,1 103172283  
   131900 /var/log/postgresql/postgresql-10-data.log
postgres  290011          postgres    2w      REG              253,1 103172283  
   131900 /var/log/postgresql/postgresql-10-data.log
postgres  290011          postgres    4w      REG              253,1 103172283  
   131900 /var/log/postgresql/postgresql-10-data.log
postgres  290011          postgres   13w      REG              253,1 103172283  
   131900 /var/log/postgresql/postgresql-10-data.log
postgres  290013          postgres    4w      REG              253,1 103172283  
   131900 /var/log/postgresql/postgresql-10-data.log
postgres  290014          postgres    4w      REG              253,1 103172283  
   131900 /var/log/postgresql/postgresql-10-data.log
postgres  290015          postgres    4w      REG              253,1 103172283  
   131900 /var/log/postgresql/postgresql-10-data.log
postgres  290016          postgres    4w      REG              253,1 103172283  
   131900 /var/log/postgresql/postgresql-10-data.log
postgres  290017          postgres    4w      REG              253,1 103172283  
   131900 /var/log/postgresql/postgresql-10-data.log
postgres  290018          postgres    4w      REG              253,1 103172283  
   131900 /var/log/postgresql/postgresql-10-data.log
postgres  290019          postgres    4w      REG              253,1 103172283  
   131900 /var/log/postgresql/postgresql-10-data.log
postgres  290020          postgres    4w      REG              253,1 103172283  
   131900 /var/log/postgresql/postgresql-10-data.log
postgres  290036          postgres    4w      REG              253,1 103172283  
   131900 /var/log/postgresql/postgresql-10-data.log
postgres  290211          postgres    4w      REG              253,1 103172283  
   131900 /var/log/postgresql/postgresql-10-data.log
postgres  290256          postgres    4w      REG              253,1 103172283  
   131900 /var/log/postgresql/postgresql-10-data.log
postgres  290257          postgres    4w      REG              253,1 103172283  
   131900 /var/log/postgresql/postgresql-10-data.log
postgres  290258          postgres    4w      REG              253,1 103172283  
   131900 /var/log/postgresql/postgresql-10-data.log

When logfile is rotated, descriptor remain to be open, but occupied space is 
not accounted by df. This leads to incorrect free space estimation on cluster.
When logfile is big enough during cluster start this can result in sudden 
cluster stop, which could be prevented by monitoring.

If I apply following patch descriptor stops leaking.

I use Ubuntu.
Description:    Ubuntu 18.04.2 LTS
Release:        18.04
Codename:       bionic

Best regards, Andrey Borodin.

diff --git a/pg_ctlcluster b/pg_ctlcluster
index 1690d3d..6039659 100755
--- a/pg_ctlcluster
+++ b/pg_ctlcluster
@@ -207,9 +207,8 @@ sub start {
     } else {
         setsid or error "could not start session: $!";
         if ($info{'logfile'}) {
-            my $fd = POSIX::open($info{'logfile'}, 
POSIX::O_WRONLY|POSIX::O_APPEND|POSIX::O_CREAT) or error "Could not open 
logfile $info{'logfile'}";
-            dup2($fd, 1);
-            dup2($fd, 2);
+            open(STDOUT, ">>$info{logfile}") or die $!;
+            open(STDERR,  '>&STDOUT')  or die $!;
         }
         exec $pg_ctl @options or error "could not exec $pg_ctl @options: $!";
     }

--- End Message ---
--- Begin Message ---
Source: postgresql-common
Source-Version: 202

We believe that the bug you reported is fixed in the latest version of
postgresql-common, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Christoph Berg <[email protected]> (supplier of updated postgresql-common package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Format: 1.8
Date: Tue, 02 Jul 2019 14:39:56 +0200
Source: postgresql-common
Architecture: source
Version: 202
Distribution: unstable
Urgency: medium
Maintainer: Debian PostgreSQL Maintainers <[email protected]>
Changed-By: Christoph Berg <[email protected]>
Closes: 930728
Changes:
 postgresql-common (202) unstable; urgency=medium
 .
   * pg_ctlcluster: Close extra log filedescriptor. Thanks Andrey Borodin!
     (Closes: #930728)
   * pg_virtualenv: Disable fakeroot while creating clusters so we don't end up
     running as root.
   * t/135_pg_virtualenv.t: New test file.
   * t/TestLib.pm: Restrict check_clean to LISTENing sockets.
   * gitlab/gitlab-ci.yml: Run blhc; fail on lintian errors.
Checksums-Sha1:
 6f5c9209b5a9c567317920fbcec443b74e7b9d2a 2309 postgresql-common_202.dsc
 a403f8e9fef49e67b2f272e6c193c4857cc158a1 213460 postgresql-common_202.tar.xz
 db0458e8835e81a48d34a538b6587353f6db8571 6009 
postgresql-common_202_source.buildinfo
Checksums-Sha256:
 41689cca087e30cfcf01fa0fd3f9493624a49c88178dad220c2e27dc44cfd6ec 2309 
postgresql-common_202.dsc
 d0243522f5de606f5df02daf0218166a5bbff8dd061dc03ecd9f01d6cf1b763f 213460 
postgresql-common_202.tar.xz
 4d5cf294a9e858339c04e10daa1334a3770623455faaae1795995acf5fc39ee8 6009 
postgresql-common_202_source.buildinfo
Files:
 f97933f828c79baf41b1f85c25dc35c6 2309 database optional 
postgresql-common_202.dsc
 4868820fb0df8133e3e8c3e0c083ab4a 213460 database optional 
postgresql-common_202.tar.xz
 9664672942e1d9a4bef53896e0f735ec 6009 database optional 
postgresql-common_202_source.buildinfo

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEXEj+YVf0kXlZcIfGTFprqxLSp64FAl0bUO4ACgkQTFprqxLS
p67FzQ/+P8Jsnl7VLD2De/6wevv0ROdCIz/2YQQNbsvBvuBR0JD9wdPJXAtqMDQd
txQS8sbNtc7ZE46KNcLIrzmE5Hon1cR0Ank6TQrc20yS0Hg9RVNfmC9LqsrX60Fz
evQZw/KKZ+MC7+uR1/+DJUk8I8eJvkulPrOeTUd9v1hDoCYdl6tPfkIlDUeoB5im
inCJ5ap0N1ZiJh2Y50t+71omXtAmV01hiFBBHXBAA4gk/fhkaUaE7B8wdP4rCDKz
kL8CBBXwna6tVk2WG6jqiJyMe1LktG3HnuuAllZZlgxuYDKEaxuKdbgU6n2qq1Ac
sDVTDekZPxp8O/DaFnmhKg2weL6D9eIrkF4qPXaQTM9u0luD8mcPm57E0fS2Lbr8
nFh0wGE/d//F5utNOfELnxn8KHkeezcp01HrHBWJW3rNA6hfBOmeSsk4w1+QiJW9
PRMXGxOHTy+yhtSC+9ZdEZBmpLeDmnYK6cjiTJ2WK8kqCUqppvWY+fYXvz2KLNxL
kDHbVG5+8cQtWGGezpITwg0ya/ddRwhDnf8psNGGefLRTu7s7Deds3OADxTRLB9D
YSp76EWSp4bDgFhKkzQRyVEvuk7BqwVIgCdloP/C1xMDWVoj6EoJNU2xizgTU87L
tQTwDo6aLjdBAOg88/hbc5LytgJU/pAwTyadq1MEDQ0fIpbOSMI=
=4uXr
-----END PGP SIGNATURE-----

--- End Message ---

Reply via email to