postgresql-[any version] from FreeBSD ports - startup problems after crash

Поиск
Список
Период
Сортировка
Искать
От
Ruslan A Dautkhanov
Тема
postgresql-[any version] from FreeBSD ports - startup problems after crash
Дата
в 05:53:13
Msg-id
44683D08.7040608@scn.ru
Список
Дерево обсуждения
postgresql-[any version] from FreeBSD ports - startup problems after crash Ruslan A Dautkhanov <rusland@scn.ru>
Re: postgresql-[any version] from FreeBSD ports - startup problems after crash Tom Lane <tgl@sss.pgh.pa.us>
Re: postgresql-[any version] from FreeBSD ports - startup problems after crash "Jim C. Nasby" <jnasby@pervasive.com>
Re: postgresql-[any version] from FreeBSD ports - startup problems after crash Tom Lane <tgl@sss.pgh.pa.us>
Re: postgresql-[any version] from FreeBSD ports - startup problems after crash "Larry Rosenman" <ler@lerctr.org>
Re: postgresql-[any version] from FreeBSD ports - startup problems after crash "Jim C. Nasby" <jnasby@pervasive.com>
Re: postgresql-[any version] from FreeBSD ports - startup Ruslan A Dautkhanov <rusland@scn.ru>
Hello !

Server rebooted occasionally after power failure.
And I have stale postmaster.pid file, so postmaster didn't start with error
    bill postgres[600]: [1-1] FATAL:  file "postmaster.pid" already exists

I think startup script and/or pg_ctl have to be written to check if that 
process really exists
and it is postmaster, so DBMS server starts after any hard reboot.

I changed the startup script block

    postgresql_command()
    {
        su -l ${postgresql_user} -c "exec ${command} ${command_args} 
${rc_arg}"
    }

to

postgresql_cmd()
{
        su -l ${postgresql_user} -c "exec ${command} ${command_args} 
${rc_arg}"
}
postgresql_command()
{
        if [ ".$1" = ".start" ]; then
                pidfile="${postgresql_data}/postmaster.pid"
                if [ -e ${pidfile} ]; then
                        #check if postmaster process really exists
                        pid_fromfile=`head -1 ${pidfile}`
                        real_pid=`ps ax | grep -v grep | grep postmaster 
| grep ${postgresql_data} | awk '{print $1}'`
                        if [ "x${pid_fromfile}" = "x${real_pid}" ]; then
                                echo "Postmater for datadir 
${postgresql_data} already run with pid $real_pid"
                        else
                                #we have stale pidfile, remove it
                                unlink $pidfile
                                #and run postmater safely
                                postgresql_cmd
                        fi
                else
                        #.pid file not exists, clean startup
                        postgresql_cmd
                fi
        else
                postgresql_cmd
        fi
}

That I hope satisfy all cases with stale .pid file...

--
Ruslan A Dautkhanov
В списке pgsql-bugs по дате отправления
От: YourSoft
Дата:
Сообщение: Re: group by
От: Tomasz Ostrowski
Дата:
FAQ