recreate missing log file in pg_ctlcluster

Bug #391119 reported by Don Bessinger
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
postgresql-common (Ubuntu)
Fix Released
Low
Martin Pitt

Bug Description

Binary package hint: postgresql-8.3

I have had this problem on both of the PostgreSql installations I've made. Contents of log file:

Log started: 2009-03-08 11:53:19
(Reading database ... 166512 files and directories currently installed.)

Preparing to replace xulrunner-1.9 1.9.0.6+nobinonly-0ubuntu0.8.04.1 (using .../xulrunner-1.9_1.9.0.7+nobinonly-0ubuntu0.8.04.1_amd64.deb) ...

Unpacking replacement xulrunner-1.9 ...

Preparing to replace firefox-3.0 3.0.6+nobinonly-0ubuntu0.8.04.1 (using .../firefox-3.0_3.0.7+nobinonly-0ubuntu0.8.04.1_amd64.deb) ...

Unpacking replacement firefox-3.0 ...

Preparing to replace firefox 3.0.6+nobinonly-0ubuntu0.8.04.1 (using .../firefox_3.0.7+nobinonly-0ubuntu0.8.04.1_all.deb) ...

Unpacking replacement firefox ...

Preparing to replace libpng12-0 1.2.15~beta5-3 (using .../libpng12-0_1.2.15~beta5-3ubuntu0.1_amd64.deb) ...

Ignoring nonregistered document `libpng12'

Unpacking replacement libpng12-0 ...

Setting up postgresql-8.3 (8.3.6-0ubuntu8.04) ...

 * Starting PostgreSQL 8.3 database server

 * Error: Could not create log file /var/log/postgresql/postgresql-8.3-main.log

   ...fail!

invoke-rc.d: initscript postgresql-8.3, action "start" failed.

dpkg: error processing postgresql-8.3 (--configure):

 subprocess post-installation script returned error exit status 1

dpkg: dependency problems prevent configuration of postgresql:

 postgresql depends on postgresql-8.3; however:

  Package postgresql-8.3 is not configured yet.

dpkg: error processing postgresql (--configure):

 dependency problems - leaving unconfigured

dpkg: dependency problems prevent configuration of postgresql-plperl-8.3:

 postgresql-plperl-8.3 depends on postgresql-8.3; however:

  Package postgresql-8.3 is not configured yet.

dpkg: error processing postgresql-plperl-8.3 (--configure):

 dependency problems - leaving unconfigured

Setting up xulrunner-1.9 (1.9.0.7+nobinonly-0ubuntu0.8.04.1) ...

Setting up firefox-3.0 (3.0.7+nobinonly-0ubuntu0.8.04.1) ...

Please restart all running instances of Firefox-3.0, or you will experience problems.

Setting up firefox (3.0.7+nobinonly-0ubuntu0.8.04.1) ...

Setting up libpng12-0 (1.2.15~beta5-3ubuntu0.1) ...

Processing triggers for libc6 ...

ldconfig deferred processing now taking place

Errors were encountered while processing:

 postgresql-8.3

 postgresql

 postgresql-plperl-8.3

Log ended: 2009-03-08 11:53:30

ProblemType: Package
Architecture: amd64
Date: Tue Jun 23 09:14:45 2009
DistroRelease: Ubuntu 8.04
ErrorMessage: subprocess post-installation script returned error exit status 1
Package: postgresql-8.3 8.3.7-0ubuntu8.04.1
PackageArchitecture: amd64
SourcePackage: postgresql-8.3
Title: package postgresql-8.3 8.3.7-0ubuntu8.04.1 failed to install/upgrade: subprocess post-installation script returned error exit status 1
Uname: Linux 2.6.24-24-generic x86_64

Revision history for this message
Don Bessinger (dbessinger) wrote :
Martin Pitt (pitti)
summary: package postgresql-8.3 8.3.7-0ubuntu8.04.1 failed to install/upgrade:
- subprocess post-installation script returned error exit status 1
+ could not create log file
Revision history for this message
Martin Pitt (pitti) wrote :

"Error: Could not create log file /var/log/postgresql/postgresql-8.3-main.log"

Please give me the output of

 ls -l /var/log/postgresql
 ls -ld /var/log/postgresql

Changed in postgresql-8.3 (Ubuntu):
status: New → Incomplete
Revision history for this message
Don Bessinger (dbessinger) wrote : Re: [Bug 391119] Re: package postgresql-8.3 8.3.7-0ubuntu8.04.1 failed to install/upgrade: subprocess post-installation script returned error exit status 1
Download full text (3.9 KiB)

ls output attached.  I actually have a script that cleans out log files that haven't been read in a certain period, so that might skew results.  I'll send fresh ls output just after I run my next update.  Thanks!

--- On Wed, 7/8/09, Martin Pitt <email address hidden> wrote:

From: Martin Pitt <email address hidden>
Subject: [Bug 391119] Re: package postgresql-8.3 8.3.7-0ubuntu8.04.1 failed to install/upgrade: subprocess post-installation script returned error exit status 1
To: <email address hidden>
Date: Wednesday, July 8, 2009, 5:05 AM

"Error: Could not create log file
/var/log/postgresql/postgresql-8.3-main.log"

Please give me the output of

 ls -l /var/log/postgresql
 ls -ld /var/log/postgresql

** Changed in: postgresql-8.3 (Ubuntu)
       Status: New => Incomplete

--
package postgresql-8.3 8.3.7-0ubuntu8.04.1 failed to install/upgrade: could not create log file
https://bugs.launchpad.net/bugs/391119
You received this bug notification because you are a direct subscriber
of the bug.

Status in “postgresql-8.3” package in Ubuntu: Incomplete

Bug description:
Binary package hint: postgresql-8.3

I have had this problem on both of the PostgreSql installations I've made.  Contents of log file:

Log started: 2009-03-08  11:53:19
(Reading database ... 166512 files and directories currently installed.)

Preparing to replace xulrunner-1.9 1.9.0.6+nobinonly-0ubuntu0.8.04.1 (using .../xulrunner-1.9_1.9.0.7+nobinonly-0ubuntu0.8.04.1_amd64.deb) ...

Unpacking replacement xulrunner-1.9 ...

Preparing to replace firefox-3.0 3.0.6+nobinonly-0ubuntu0.8.04.1 (using .../firefox-3.0_3.0.7+nobinonly-0ubuntu0.8.04.1_amd64.deb) ...

Unpacking replacement firefox-3.0 ...

Preparing to replace firefox 3.0.6+nobinonly-0ubuntu0.8.04.1 (using .../firefox_3.0.7+nobinonly-0ubuntu0.8.04.1_all.deb) ...

Unpacking replacement firefox ...

Preparing to replace libpng12-0 1.2.15~beta5-3 (using .../libpng12-0_1.2.15~beta5-3ubuntu0.1_amd64.deb) ...

Ignoring nonregistered document `libpng12'

Unpacking replacement libpng12-0 ...

Setting up postgresql-8.3 (8.3.6-0ubuntu8.04) ...

 * Starting PostgreSQL 8.3 database server

 * Error: Could not create log file /var/log/postgresql/postgresql-8.3-main..log

   ...fail!

invoke-rc.d: initscript postgresql-8.3, action "start" failed.

dpkg: error processing postgresql-8.3 (--configure):

 subprocess post-installation script returned error exit status 1

dpkg: dependency problems prevent configuration of postgresql:

 postgresql depends on postgresql-8.3; however:

  Package postgresql-8.3 is not configured yet.

dpkg: error processing postgresql (--configure):

 dependency problems - leaving unconfigured

dpkg: dependency problems prevent configuration of postgresql-plperl-8.3:

 postgresql-plperl-8.3 depends on postgresql-8.3; however:

  Package postgresql-8.3 is not configured yet.

dpkg: error processing postgresql-plperl-8.3 (--configure):

 dependency problems - leaving unconfigured

Setting up xulrunner-1.9 (1.9.0.7+nobinonly-0ubuntu0.8.04.1) ...

Setting up firefox-3.0 (3.0.7+nobinonly-0ubuntu0.8.04.1) ...

Please restart all running instances of Firefox-3.0, or you will experience problems.

Setting up fir...

Read more...

Revision history for this message
Martin Pitt (pitti) wrote : Re: package postgresql-8.3 8.3.7-0ubuntu8.04.1 failed to install/upgrade: could not create log file

> drwxrwxr-t 2 root adm 4096 2009-03-08 12:00 /var/log/postgresql

That would be it then. It needs to be

drwxrwxr-t 2 root postgres 4096 5. Jul 06:27 /var/log/postgresql

(group "postgres"), and this is how it is created by default. postgresql doesn't run as root, and thus needs this directory to be writable.

Changed in postgresql-8.3 (Ubuntu):
status: Incomplete → Invalid
Revision history for this message
Don Bessinger (dbessinger) wrote :

I see this bug is marked as Invalid, but the problem persists. Postgresql still fails to update via Synaptic. Attached are log files & directory listings. If these should go elsewhere, let me know.

Revision history for this message
Martin Pitt (pitti) wrote :

As I said, it seems that you or something wedged the permissions of /var/log/postgresql/. You can fix it locally with

  sudo chgrp postgres /var/log/postgresql/

in a Terminal window.

Revision history for this message
Don Bessinger (dbessinger) wrote :

OK, but if you take a look at the files I attached to the last post, you see that my /var/log/postgresql directory has owner "root" and group "postgres". Additionally, the log files are now present in that directory, but Postgresql still fails to update via Synaptic Package Manager. Should I start a new bug? Sorry about my ignorance, but this is the first time I've submitted a bug anywhere, so I'm not sure what the protocol is. :)

Revision history for this message
Martin Pitt (pitti) wrote :

Ah, so now it fails with

  2009-07-17 06:27:15 EDT FATAL: could not access private key file "server.key": Permission denied

(This is reported in bug 390748 as well). Assuming that you didn't change it manually, what does

  ls -l /etc/ssl/private/ssl-cert-snakeoil.key

show? It should be

  -rw-r----- 1 root ssl-cert 887 12. Mai 2006 /etc/ssl/private/ssl-cert-snakeoil.key

and "id postgres" should be

  uid=31(postgres) gid=32(postgres) groups=32(postgres),103(ssl-cert)

Revision history for this message
Don Bessinger (dbessinger) wrote :

For the sake of clarity, I changed the group ownership of the /var/log/postgresql directory per the instructions in your first post. I had not changed the ownership before that, so the ownership that showed up in the log is how it got created in either an install or an update.

I have not manually changed the ssl-cert-snakeoil.key's ownership or permissions, and the output you requested is:

[code]
~:ls -l /etc/ssl/private/ssl-cert-snakeoil.key
-rw-r----- 1 root ssl-cert 887 2008-09-12 16:55 /etc/ssl/private/ssl-cert-snakeoil.key
[/code]

Thanks, and hope that helps.

Revision history for this message
Martin Pitt (pitti) wrote : Re: [Bug 391119] Re: package postgresql-8.3 8.3.7-0ubuntu8.04.1 failed to install/upgrade: could not create log file

Hello
Don Bessinger [2009-07-19 16:23 -0000]:
> For the sake of clarity, I changed the group ownership of the
> /var/log/postgresql directory per the instructions in your first post.
> I had not changed the ownership before that, so the ownership that
> showed up in the log is how it got created in either an install or an
> update.

Indeed, sorry. The real problem was that the log file disappeared
entirely for some reason. It's created by pg_createcluster or when
installed. Any idea why/when it disappeared?

I reopen this bug to improve handling of this case.

 status triaged
 importance low
 title recreate missing log file in pg_ctlcluster

> ~:ls -l /etc/ssl/private/ssl-cert-snakeoil.key
> -rw-r----- 1 root ssl-cert 887 2008-09-12 16:55 /etc/ssl/private/ssl-cert-snakeoil.key

OK, that looks fine. What's the output of "id postgres", does it match
the "should be" output I mentioned in the previous comment?

Thanks,

Martin

--
Martin Pitt | http://www.piware.de
Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)

Changed in postgresql-8.3 (Ubuntu):
importance: Undecided → Low
status: Invalid → Triaged
summary: - package postgresql-8.3 8.3.7-0ubuntu8.04.1 failed to install/upgrade:
- could not create log file
+ recreate missing log file in pg_ctlcluster
affects: postgresql-8.3 (Ubuntu) → postgresql-common (Ubuntu)
Changed in postgresql-common (Ubuntu):
assignee: nobody → Martin Pitt (pitti)
Revision history for this message
Don Bessinger (dbessinger) wrote :

As I posted on July 8, I have a script that clears out log files that haven't been accessed in 3 or more days. If a missing log file is the problem, I'll make sure that the log files in the /var/log/postgresql directory remain untouched.

Meanwhile, here's the output of id postgres:

~:id postgres
uid=1001(postgres) gid=1001(postgres) groups=1001(postgres)

which does not match the "should be" case output you submitted:

   > uid=31(postgres) gid=32(postgres) groups=32(postgres),103(ssl-cert)

Thanks for your time and effort, and hope this helps.

Revision history for this message
Martin Pitt (pitti) wrote : Re: [Bug 391119] Re: recreate missing log file in pg_ctlcluster

Don Bessinger [2009-07-19 19:05 -0000]:
> As I posted on July 8, I have a script that clears out log files that
> haven't been accessed in 3 or more days. If a missing log file is the
> problem, I'll make sure that the log files in the /var/log/postgresql
> directory remain untouched.

Right, that's the problem then. I'll fix this for Ubuntu 9.10, but
this is not a fix that meets the criteria for a stable update.

> Meanwhile, here's the output of id postgres:
>
> ~:id postgres
> uid=1001(postgres) gid=1001(postgres) groups=1001(postgres)

Ah, as I expected. Any idea why postgres was removed from the ssl-cert
group? Also, it is in the ID range of normal users, not system users.
Do you happen to use some central account service which also serves
the 'postgres' user (it shouldn't)?

You should be able to start PostgreSQL again after

  sudo adduser postgres ssl-cert

(or disabling SSL in postgresql.conf).

Thanks, Martin

Revision history for this message
Don Bessinger (dbessinger) wrote :

OK, sounds good. I understand that this certainly isn't a critical update issue, so I'll keep an eye out for Ubuntu 9.10.

In answer to your first question, I created the postgres user manually at some point during the Postgresql installation process. If memory serves, I was simply following along with the documentation (don't remember exactly where in the docs) and didn't realize that the GIDs were divided between system and regular users. As you might have guessed, I'm not the most experienced Linux administrator.

As to the removal of the postgres user from the ssl-cert group, I have no idea. Monkeying around with that sort of thing is not something I typically do, though I don't remember adding postgres to that group when I set it up. So, it's probably not that something went horribly wrong and changed my group memberships, but that it never was in the group in the first place.

Thanks for all the work!

Revision history for this message
Don Bessinger (dbessinger) wrote :

I just updated my system again, and of course, the Postgresql failed. Now that you've shown me where to look, I dug around and see that none of the files in the /etc/postgresql/8.3/main are owned by postgres or are in the postgres group. that would certainly explain the failure to configure Postgresql during updates. Here's the directory listing:

:~$ ls -la /etc/postgresql/8.3/main
total 44
drwxr-xr-x 2 root root 4096 2009-02-22 14:33 .
drwxr-xr-x 3 root root 4096 2009-01-18 10:52 ..
-rw-r--r-- 1 root root 316 2009-01-18 10:52 environment
-rw-r----- 1 ntp ntp 3621 2009-01-18 10:52 pg_hba.conf
-rw-r----- 1 ntp ntp 1460 2009-01-18 10:52 pg_ident.conf
-rw-r--r-- 1 ntp ntp 16681 2009-02-22 14:28 postgresql.conf
-rw-r--r-- 1 root root 378 2009-01-18 10:52 start.conf

The update fails on trying to open the pg_hba.conf file. I'm attaching a .zip file with the directory listing output, the postgresql logs, and the update manager's term.log file. Thanks, and hope this helps.

Revision history for this message
Martin Pitt (pitti) wrote :

Don Bessinger [2009-07-21 13:19 -0000]:
> In answer to your first question, I created the postgres user manually
> at some point during the Postgresql installation process.

Ah, that'd explain why it's > 1000 and not in the ssl-cert group.

Thanks!

Revision history for this message
Martin Pitt (pitti) wrote :

r965

Changed in postgresql-common (Ubuntu):
status: Triaged → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package postgresql-common - 103

---------------
postgresql-common (103) unstable; urgency=low

  * Move the lsb-release dependency of p-common to a recommends of
    p-client-common. (Closes: #562642)
  * Drop Oliver from Uploaders:, he has not been active any more for years.
  * t/005_PgCommon.t: Add '.' to library search path, so that this prefers
    testing PgCommon.pm from the source tree.
  * t/005_PgCommon.t: Add test cases for {set,disable,replace}_conf_value().
  * PgCommon.pm, replace_conf_value(): Do not append the new parameter if the
    old is not found.
  * PgCommon.pm, {set,disable,replace}_conf_value(): Intercept errors on
    writing data (which could happen when running out of disk space). Write
    into a new file and rename it in the end, instead of directly writing into
    the original file. Thanks to Yann Dirson for the original patch.
    (Closes: #549206)
  * pg_createcluster: Change effective gid as well when setting the socket
    directory, to avoid moving postgresql.conf's group to root (which would
    happen with the previous change).
  * Add t/042_upgrade_tablespaces.t: Test upgrading a cluster with
    tablespaces. Since this is not currently supported (and hard to do in an
    automated fashion due to the nature of tablespaces), just check that this
    errors out with a sane message and does not do any damage.
  * pg_upgradecluster: Add an early check for tablespaces. (Closes: #523574)
  * pg_lsclusters: Fix undefined value if owneruid cannot be determined (which
    can happen in special setups). Thanks to Daniel Pittman! (Closes: #541434)
  * t/020_create_sql_remove.t: Verify permissions of the data and
    configuration directories.
  * pg_createcluster: Make /etc/postgresql/<version> and
    /var/lib/postgresql/<version> owned by 'postgres', so that they can be
    administrated with 'postgres' privileges. Update t/030_errors.t
    accordingly. (LP: #236704, Closes: #525294)
  * t/020_create_sql_remove.t: Check that a missing log file is recreated by
    pg_ctlcluster (if it has enough permissions).
  * pg_ctlcluster: Make re-creation of log file actually work. (LP: #391119,
    #372476)
 -- Martin Pitt <email address hidden> Wed, 30 Dec 2009 23:06:10 +0100

Changed in postgresql-common (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.