Re: switch UNLOGGED to LOGGED

From: Leonardo Francalanci <m_lists(at)yahoo(dot)it>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: switch UNLOGGED to LOGGED
Date: 2011-05-19 12:52:46
Message-ID: 999953.89059.qm@web29012.mail.ird.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> I'd guess some WAL record arising from the post-crash master restart makes
the
> standby do so. When a crash isn't involved, the commit or abort record is
>that
> signal. You could test and find out how it happens after a master crash with
>a
> procedure like this:
>
> 1. Start a master and standby on the same machine.
> 2. Connect to master; CREATE TABLE t(); BEGIN; ALTER TABLE t ADD c int;
> 3. kill -9 -`head -n1 $master_PGDATA/postmaster.pid`
> 4. Connect to standby and confirm that t is still locked.
> 5. Attach debugger to standby startup process and set breakpoints on
> StandbyReleaseLocks and StandbyReleaseLocksMany.
> 6. Restart master.

Well yes, based on the test the stack is something like:

StandbyReleaseLocksManyStandbyReleaseOldLocks
ProcArrayApplyRecoveryInfo
xlog_redo

It's not very clear to me what ProcArrayApplyRecoveryInfo does (not too
familiar with the standby part I guess) but I see it's called by xlog_redo in
the "info == XLOG_CHECKPOINT_SHUTDOWN" case and by StartupXLOG.

But I don't know if calling ResetUnloggedRelations before
the call to ProcArrayApplyRecoveryInfo in xlog_redo makes sense...
if it makes sense, it would solve the problem of the stray files in
the master crashing case I guess?

> > > When you promote the standby, though,
> > ShutdownRecoveryTransactionEnvironment()
> > > releases the locks.

If I understand the code, ResetUnloggedRelations is called before
ShutdownRecoveryTransactionEnvironment, so that part shouldn't be
an issue

Leonardo

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2011-05-19 14:18:20 Re: LOCK DATABASE
Previous Message Robert Haas 2011-05-19 12:47:08 Re: cache estimates, cache access cost