From 7dbb60693820c20b562c12f58040c9871d6ab787 Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Mon, 20 Oct 2014 23:43:46 +0200 Subject: Flush unlogged table's buffers when copying or moving databases. CREATE DATABASE and ALTER DATABASE .. SET TABLESPACE copy the source database directory on the filesystem level. To ensure the on disk state is consistent they block out users of the affected database and force a checkpoint to flush out all data to disk. Unfortunately, up to now, that checkpoint didn't flush out dirty buffers from unlogged relations. That bug means there could be leftover dirty buffers in either the template database, or the database in its old location. Leading to problems when accessing relations in an inconsistent state; and to possible problems during shutdown in the SET TABLESPACE case because buffers belonging files that don't exist anymore are flushed. This was reported in bug #10675 by Maxim Boguk. Fix by Pavan Deolasee, modified somewhat by me. Reviewed by MauMau and Fujii Masao. Backpatch to 9.1 where unlogged tables were introduced. --- src/include/access/xlog.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/include/access/xlog.h') diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 0f068d91f38..ca35f3e65f7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -253,6 +253,8 @@ extern bool XLOG_DEBUG; /* These indicate the cause of a checkpoint request */ #define CHECKPOINT_CAUSE_XLOG 0x0020 /* XLOG consumption */ #define CHECKPOINT_CAUSE_TIME 0x0040 /* Elapsed time */ +#define CHECKPOINT_FLUSH_ALL 0x0080 /* Flush all pages, including those + * belonging to unlogged tables */ /* Checkpoint statistics */ typedef struct CheckpointStatsData -- cgit v1.2.3