From: Noah Misch <noah@leadboat.com>
To: pgsql-bugs@postgresql.org
To: dilipbalaut@gmail.com
Cc: robertmhaas@gmail.com
Subject: Re: STRATEGY=WAL_LOG missing checkpoint interlocks and sync
Date: Thu, 1 Feb 2024 15:28:28 -0800
Message-ID: <20240201232828.b1.nmisch@google.com> (raw)
In-Reply-To: <20240130195003.0a.nmisch@google.com>
References: <20240130195003.0a.nmisch@google.com>
On Tue, Jan 30, 2024 at 11:50:03AM -0800, Noah Misch wrote:
> (1) CreateDirAndVersionFile() uses a code sequence: XLogInsert(), XLogFlush(),
> write(PG_VERSION). This is missing the interlock with checkpoints, which
> pd_lsn usually secures. This breaks when one takes a base backup between the
> XLogInsert() and the write(). The transam/README "action first and then write
> a WAL entry" strategy works well. createdb_failure_callback() will remove the
> whole directory on failure.
>
> (2) RelationMapCopy() reasons that it doesn't need RelationMappingLock.
> CheckPointRelationMap() relies on RelationMappingLock to avoid completing a
> checkpoint between the WAL and the sync. A base backup taken in the middle of
> write_relmap_file() has no relmap after recovery.
>
> (3) CreateDirAndVersionFile() populates the PG_VERSION file without syncing
> it. An OS crash after the next checkpoint may leave PG_VERSION empty or
> missing. Let's fsync the file immediately. I used LazyFS to confirm the
> defect and fix. Though I was skeptical about adding a wait event in back
> branches, I plan to do so anyway. Commit 368ffde got away with it, and we do
> have this pattern of the sync event being separate from the write event.
Pushed at commit 0b6517a.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noah@leadboat.com, dilipbalaut@gmail.com, robertmhaas@gmail.com
Subject: Re: STRATEGY=WAL_LOG missing checkpoint interlocks and sync
In-Reply-To: <20240201232828.b1.nmisch@google.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox