Re: pg_upgrade and wraparound

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: pg_upgrade and wraparound
Дата
Msg-id 20180611170812.7ypf6xs6dlteo57j@alap3.anarazel.de
обсуждение исходный текст
Ответ на Re: pg_upgrade and wraparound  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: pg_upgrade and wraparound
Список pgsql-general
On 2018-06-09 15:52:26 -0400, Tom Lane wrote:
> Adrian Klaver <adrian.klaver@aklaver.com> writes:
> > On 06/09/2018 03:46 AM, Alexander Shutyaev wrote:
> >> The upgrade operation failed after several hours with the following error:
> >> database is not accepting commands to avoid wraparound data loss in 
> >> database with OID 0
> 
> > Do you know which database has an OID of 0?
> 
> Well, none do, so the correct question is what is passing an invalid
> database OID to the code that's complaining.  This sure looks like a
> bug, though I'm not sure we have enough info to locate it.

It sure looks like ShmemVariableCache->oldestXidDB isn't initialized.
As far as I remember we just initialize that from a checkpoint at
startup.   I suspect the issue is that pg_resetwal does:
    if (set_xid != 0)
    {
        ControlFile.checkPointCopy.nextXid = set_xid;

        /*
         * For the moment, just set oldestXid to a value that will force
         * immediate autovacuum-for-wraparound.  It's not clear whether adding
         * user control of this is useful, so let's just do something that's
         * reasonably safe.  The magic constant here corresponds to the
         * maximum allowed value of autovacuum_freeze_max_age.
         */
        ControlFile.checkPointCopy.oldestXid = set_xid - 2000000000;
        if (ControlFile.checkPointCopy.oldestXid < FirstNormalTransactionId)
            ControlFile.checkPointCopy.oldestXid += FirstNormalTransactionId;
        ControlFile.checkPointCopy.oldestXidDB = InvalidOid;
    }

but we have codepath that doesn't check for oldestXidDB being
InvalidOid.  Not great.

Greetings,

Andres Freund


В списке pgsql-general по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: pg_upgrade and wraparound
Следующее
От: Tom Lane
Дата:
Сообщение: Re: pg_upgrade and wraparound