Concrete proposal for large objects and MVCC - Mailing list pgsql-hackers

From Tom Lane
Subject Concrete proposal for large objects and MVCC
Date
Msg-id 22768.1118418488@sss.pgh.pa.us
Whole thread Raw
Responses Re: Concrete proposal for large objects and MVCC
Re: Concrete proposal for large objects and MVCC
List pgsql-hackers
I spent a little bit of time thinking about what it would mean exactly
for large-object operations to obey MVCC, and decided that there are
more worms in that can than I had realized.  Part of the problem is
that we have no concept of a lock on an individual LO, and thus
operations that really should be serialized, such as DROP, aren't going
to work very well.  We could implement DROP as the equivalent ofDELETE FROM pg_largeobject WHERE loid = nnn;
with an MVCC snapshot --- but there is no guarantee that we won't miss
a page that someone else is concurrently inserting into that same large
object.

So what I'm thinking is that the prudent course is to leave writing
semantics as they are, namely SnapshotNow rules.  (What this means
in practice is you get "tuple concurrently updated" errors if two
transactions try to write the same page of the same LO concurrently.
We have seen few if any complaints about that error in connection with
LO operations, so ISTM there's not a problem there that needs solving.)

The problem we do need to solve is letting pg_dump have a stable view
of the database's large objects.  I propose that we can fix this in
a suitably narrow way by making the following definition:
* A large object descriptor opened for read-only access saves  the current ActiveSnapshot and uses that snapshot to
read pg_largeobject for the duration of its existence.
 
* A large object descriptor opened for write-only or read-write  access uses SnapshotNow, same as before.

This avoids the risk of creating any serious backwards-compatibility
issues: if there's anyone out there who does need SnapshotNow reads,
they just have to be sure to open the LO in read-write mode to have
fully backward compatible operation.

Comments, objections?
        regards, tom lane


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: User Quota Implementation
Next
From: "Marc G. Fournier"
Date:
Subject: Re: Bug in pg_restore ... ?