postgres init script fails uncleanly if cluster directory is missing

Bug #210322 reported by Philip Hofstetter
2
Affects Status Importance Assigned to Milestone
postgresql-common (Ubuntu)
Fix Released
Low
Martin Pitt

Bug Description

Binary package hint: postgresql-common

On this particular setup, the cluster home directory /var/lib/postgresql is mounted to its own partition.

By accident, the directory wasn't mounted when I tried to launch postgres. Instead of a precise error message notifying me about the problem, I got a heap of perl error messages. While it's pure cosmetics, I think the scripts should check for basic errors like that and not bail out showing a bunch of perl errors.

Steps to reproduce:
- Create a postgres-cluster
- Remove the parent directory of said cluster (or unmount its partition)
- Try to launch postgres.

Expected tesults:
- Error-Message explaining the problem

Actual results:
root@vmmepha:~# /etc/init.d/postgresql-8.3 start
 * Starting PostgreSQL 8.3 database server
 * Use of uninitialized value in getpwuid at /usr/bin/pg_ctlcluster line 433.
Use of uninitialized value in getgrgid at /usr/bin/pg_ctlcluster line 436.
Use of uninitialized value in concatenation (.) or string at /usr/share/postgresql-common/PgCommon.pm line 649.
Use of uninitialized value in numeric eq (==) at /usr/share/postgresql-common/PgCommon.pm line 658.
Use of uninitialized value in numeric eq (==) at /usr/share/postgresql-common/PgCommon.pm line 658.
Use of uninitialized value in numeric eq (==) at /usr/share/postgresql-common/PgCommon.pm line 658.
Use of uninitialized value in numeric eq (==) at /usr/share/postgresql-common/PgCommon.pm line 658.
Use of uninitialized value in numeric eq (==) at /usr/share/postgresql-common/PgCommon.pm line 658.
Use of uninitialized value in numeric eq (==) at /usr/share/postgresql-common/PgCommon.pm line 658.
Use of uninitialized value in numeric eq (==) at /usr/share/postgresql-common/PgCommon.pm line 658.
Use of uninitialized value in numeric eq (==) at /usr/share/postgresql-common/PgCommon.pm line 658.
Use of uninitialized value in numeric eq (==) at /usr/share/postgresql-common/PgCommon.pm line 658.
Use of uninitialized value in numeric eq (==) at /usr/share/postgresql-common/PgCommon.pm line 658.
Use of uninitialized value in numeric eq (==) at /usr/share/postgresql-common/PgCommon.pm line 658.
Use of uninitialized value in numeric eq (==) at /usr/share/postgresql-common/PgCommon.pm line 658.
Use of uninitialized value in scalar assignment at /usr/share/postgresql-common/PgCommon.pm line 666.
Use of uninitialized value in scalar assignment at /usr/share/postgresql-common/PgCommon.pm line 667.
Use of uninitialized value in numeric ne (!=) at /usr/share/postgresql-common/PgCommon.pm line 668.
Use of uninitialized value in numeric ne (!=) at /usr/share/postgresql-common/PgCommon.pm line 669.
Use of uninitialized value in numeric ne (!=) at /usr/bin/pg_ctlcluster line 445.
pg_controldata: could not open file "/var/lib/postgresql/8.3/main/global/pg_control" for reading: No such file or directory
Error: Could not parse locale out of pg_controldata output
   ...fail!

$ lsb_release -rd
Description: Ubuntu hardy (development branch)
Release: 8.04

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

IMHO, the "could not open file "/var/lib/postgresql/8.3/main/global/pg_control" for reading: No such file or directory" message is clear enough. It would be nice to suppress all the perl warnings, of course.

Changed in postgresql-common:
importance: Undecided → Low
status: New → Confirmed
Revision history for this message
Martin Pitt (pitti) wrote :

Reproduced, and test case committed to postgresql-common development trunk.

Changed in postgresql-common:
assignee: nobody → pitti
status: Confirmed → In Progress
Revision history for this message
Martin Pitt (pitti) wrote :

Fixed in development trunk, will upload to Debian soon.

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

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

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

  * t/030_errors.t: Add various test cases for stopping stopped clusters with
    stale or corrupt PID files, with and without --force. This reproduces
    #473879.
  * pg_ctlcluster: On stop, clean up stale/corrupt PID files if the server is
    not running. Also fix a taint error and simplify the code a bit.
    (Closes: #473879)
  * t/030_errors.t: Test graceful handling of absent /var/lib/postgresql.
    (Reproduces LP #210322). Adapt 020_create_sql_remove.t accordingly.
  * pg_ctlcluster: Check early whether the data directory exists and is
    accessible, to avoid lots of Perl warning clutter. (LP: #210322)
  * pg_createcluster POD: Clarify what "integrating existing cluster data
    directory" means: configuration files must already be present, we cannot
    create them out of thin air. (Closes: #475954)
  * pg_maintenance: Sort versions for predictable output (looks nicer and
    unbreaks the test suite).

 -- Ubuntu Archive Auto-Sync <email address hidden> Fri, 02 May 2008 02:23:00 +0100

Changed in postgresql-common:
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.