Re: AW: AW: AW: WAL-based allocation of XIDs is insecure - Mailing list pgsql-hackers

From Tom Lane
Subject Re: AW: AW: AW: WAL-based allocation of XIDs is insecure
Date
Msg-id 6189.983897892@sss.pgh.pa.us
Whole thread Raw
In response to AW: AW: AW: WAL-based allocation of XIDs is insecure  (Zeugswetter Andreas SB <ZeugswetterA@wien.spardat.at>)
Responses Re: AW: AW: AW: WAL-based allocation of XIDs is insecure  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Zeugswetter Andreas SB  <ZeugswetterA@wien.spardat.at> writes:
> Is it so hard to swap ? First write page to log then modify in shmem. 
> Then those pages would have additional value, because
> then utilities could do all sorts of things with those pages.

After thinking about this a little, I believe I see why Vadim did it
the way he did.  Suppose we tried to make the code sequence be
obtain write lock on buffer;XLogOriginalPage(buffer);   // copy page to xlog if first since ckptmodify
buffer;XLogInsert(xlogentry for modification);mark buffer dirty and release write lock;
 

so that the saving of the original page is a separate xlog entry from
the modification data.  Looks easy, and it'd sure simplify XLogInsert
a lot.  The only problem is it's wrong.  What if a checkpoint occurs
between the two XLOG records?

The decision whether to log the whole buffer has to be atomic with the
actual entry of the xlog record.  Unless we want to hold the xlog insert
lock for the entire time that we're (eg) splitting a btree page, that
means we log the buffer after the modification work is done, not before.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Christof Petig
Date:
Subject: Re: Query Planning time increased 3 times on 7.1 compared to 7.0.3
Next
From: Bruce Momjian
Date:
Subject: Re: How to shoot yourself in the foot: kill -9 postmaster