Обсуждение: pgsql: Make it reasonably safe to use pg_ctl to start the postmaster

Поиск
Список
Период
Сортировка

pgsql: Make it reasonably safe to use pg_ctl to start the postmaster

От
tgl@postgresql.org (Tom Lane)
Дата:
Log Message:
-----------
Make it reasonably safe to use pg_ctl to start the postmaster from a boot-time
script.

To do this, have pg_ctl pass down its parent shell's PID in an environment
variable PG_GRANDPARENT_PID, and teach CreateLockFile() to disregard that PID
as a false match if it finds it in postmaster.pid.  This allows us to cope
with one level of postgres-owned shell process even with pg_ctl in the way,
so it's just as safe as starting the postmaster directly.  You still have to
be careful about how you write the initscript though.

Adjust the comments in contrib/start-scripts/ to not deprecate use of
pg_ctl.  Also, fix the ROTATELOGS option in the OSX script, which was
indulging in exactly the sort of unsafe coding that renders this fix
pointless :-(.  A pipe inside the "sudo" will probably result in more
than one postgres-owned process hanging around.

Modified Files:
--------------
    pgsql/contrib/start-scripts:
        freebsd (r1.4 -> r1.5)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/contrib/start-scripts/freebsd?r1=1.4&r2=1.5)
        linux (r1.8 -> r1.9)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/contrib/start-scripts/linux?r1=1.8&r2=1.9)
    pgsql/contrib/start-scripts/osx:
        PostgreSQL (r1.3 -> r1.4)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/contrib/start-scripts/osx/PostgreSQL?r1=1.3&r2=1.4)
    pgsql/src/backend/utils/init:
        miscinit.c (r1.176 -> r1.177)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/init/miscinit.c?r1=1.176&r2=1.177)
    pgsql/src/bin/pg_ctl:
        pg_ctl.c (r1.111 -> r1.112)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/bin/pg_ctl/pg_ctl.c?r1=1.111&r2=1.112)