Re: indexes no longer used after shutdown during reindexing

From: Tomas Vondra <tv(at)fuzzy(dot)cz>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: indexes no longer used after shutdown during reindexing
Date: 2012-01-22 23:40:03
Message-ID: 4F1C9E53.30304@fuzzy.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 20.1.2012 19:47, Matt Dew wrote:
> On 01/13/2012 02:49 PM, Tomas Vondra wrote:
>> On 13.1.2012 22:20, Tom Lane wrote:
>>> Matt Dew<mattd(at)consistentstate(dot)com> writes:
>>>> An interesting sidenote we realized. the nice system shutdown script
>>>> /etc/init.d/postgres doesn't actually wait for the db to be down, it
>>>> just waits for pg_ctl to return.
>>>
>>> By default, "pg_ctl stop" does wait for the server to shut down ...
>>
>> Not really. It waits for up to 60 seconds and if the shutdown was not
>> successful (as there was a connected client), it prints a message to
>> the log
>>
>> pg_ctl: server does not shut down
>> HINT: The "-m fast" option immediately disconnects sessions
>> rather than
>>
>> and returns 1.
>>
>> If you really need to wait for shutdown, you need to add "-w" to the
>> command line, use "-m fast" or "-m immediate".
>>
>> But even ignoring the return value should not cause corruption IMHO.
>
> Thanks Tom and Tomas,
> I remember -w now, but I'd long forgotten about it.
>
> If the pg_ctl returns a 1 but the machine physically powers off, there
> is a chance for corruption though right? Postgres is trying to write
> stuff to disk and clean up and BAM power goes out. ?
>
> There is a chance for corruption though if the machine physically powers
> off after the pg_ctl return

There are various types of corruption. If you power off the system
before the database properly shuts down, the data files will be
corrupted. But this should be fixed on the next database startup - the
database should find out it was not switched properly and perform a
recovery (replay the WAL logs).

So yes, it would be corrupted but fixed on the next startup. And thus
should not cause issues like the one you describe.

Tomas

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Maxim Boguk 2012-01-22 23:58:35 Question about (probably wrong) index scan cost for conditional indexes
Previous Message David W Noon 2012-01-22 19:41:24 Re: hash options