Re: smgrwrite() without LockBuffer(was RE: Shouldn't flush dirty buffers at shutdown ?) - Mailing list pgsql-hackers

From Tom Lane
Subject Re: smgrwrite() without LockBuffer(was RE: Shouldn't flush dirty buffers at shutdown ?)
Date
Msg-id 5341.959312413@sss.pgh.pa.us
Whole thread Raw
In response to smgrwrite() without LockBuffer(was RE: Shouldn't flush dirty buffers at shutdown ?)  ("Hiroshi Inoue" <Inoue@tpf.co.jp>)
List pgsql-hackers
"Hiroshi Inoue" <Inoue@tpf.co.jp> writes:
> As far as I see,PostgreSQL doesn't call LockBuffer() before
> calling smgrwrite(). This seems to mean that smgrwrite()
> could write buffers to disk which are being changed by
> another backend. If the(another) backend was aborted by
> some reason the buffer page would remain half-changed.

Hmm ... looks fishy to me too.  Seems like we ought to hold
BUFFER_LOCK_SHARE on the buffer while dumping it out.  It
wouldn't matter under normal circumstances, but as you say
there could be trouble if the other backend crashed before
it could mark the buffer dirty again, or if we had a system
crash before the dirtied page got written again.

Vadim, what do you think?
        regards, tom lane


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: vacuum analyze feedback
Next
From: Lamar Owen
Date:
Subject: PostgreSQL 7.0-3 RPMset available.