DDL result is lost by CREATE DATABASE with WAL_LOG strategy - Mailing list pgsql-hackers

From Ryo Matsumura (Fujitsu)
Subject DDL result is lost by CREATE DATABASE with WAL_LOG strategy
Date
Msg-id TYCPR01MB6868677E499C9AD5123084B5E8A39@TYCPR01MB6868.jpnprd01.prod.outlook.com
Whole thread Raw
Responses Re: DDL result is lost by CREATE DATABASE with WAL_LOG strategy
Re: DDL result is lost by CREATE DATABASE with WAL_LOG strategy
List pgsql-hackers
Hi, hackers.

I found that CREATE DATABASE occurs lost of DDL result after crash server.
The direct cause is that the checkpoint skips sync for page of template1's main fork
because buffer status is not marked as BM_PERMANENT in BufferAlloc().

Have you any knowledge about it?

Reproduction:
1) Do initdb.
2) Start server.
3) Connect to 'postgres' database.
4) Execute CREATE DATABASE statement with WAL_LOG strategy.
5) Connect to 'template1' database.
6) Update pg_class by executing some DDL.
7) Do checkpoint.
8) Crash server.

[src/backend/storage/buffer/bufmgr.c]
1437     if (relpersistence == RELPERSISTENCE_PERMANENT || forkNum == INIT_FORKNUM)
1438         buf_state |= BM_TAG_VALID | BM_PERMANENT | BUF_USAGECOUNT_ONE;
1439     else
             !!! walk this route !!!
1440         buf_state |= BM_TAG_VALID | BUF_USAGECOUNT_ONE;

The above is occured by the following call.
The argument 'permanent' of ReadBufferWithoutRelcache() is passed to
BufferAlloc() as 'relpersistence'.

[src/backend/commands/]
 298         buf = ReadBufferWithoutRelcache(rnode, MAIN_FORKNUM, blkno,
 299                                         RBM_NORMAL, bstrategy, false);

Regards
Ryo Matsumura



pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: [PATCH] Use indexes on the subscriber when REPLICA IDENTITY is full on the publisher
Next
From: Tom Lane
Date:
Subject: Re: some namespace.c refactoring