Re: TRUNCATE SERIALIZABLE and frozen COPY - Mailing list pgsql-hackers

From Kevin Grittner
Subject Re: TRUNCATE SERIALIZABLE and frozen COPY
Date
Msg-id 20121109142223.77850@gmx.com
Whole thread Raw
In response to TRUNCATE SERIALIZABLE and frozen COPY  (Simon Riggs <simon@2ndQuadrant.com>)
Responses Re: TRUNCATE SERIALIZABLE and frozen COPY  (Simon Riggs <simon@2ndQuadrant.com>)
Re: TRUNCATE SERIALIZABLE and frozen COPY  (Merlin Moncure <mmoncure@gmail.com>)
Re: TRUNCATE SERIALIZABLE and frozen COPY  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
Robert Haas wrote:

> What I've been wondering since this last came up is whether we
> could use some variant of the SIREAD locks Kevin introduced for SSI
> to handle this case - essentially have the transaction doing the
> TRUNCATE make an entry in the lock table that will force a
> serialization failure for any backend which accesses the table with
> a snapshot that can't see the truncating transaction's XID.

It seems to me that the goal would be to make this semantically
idential to the behavior users would see if an unqualified DELETE
were run against the table rather than a TRUNCATE. To wit:

(1) Any attempt to read from the truncated table would not block. The
pg_class version included in the transaction's snapshot would
determine which heap and indexes were accessed. If the reading
transaction were SERIALIZABLE, it would generate a read-write
conflict out to the truncating transaction.

(2) Any attempt to write to the truncated table would block until the
end of the transaction which is doing the truncation. If the
truncating transaction rolls back, it proceeds normally against the
old data. Otherwise: If the transaction is READ COMMITTED, follow the
pg_class update links. At more strict isolation levels, generate a
write conflict error.

I'm not sure where any new use of the predicate locking system would
come into play in that, other than properly handling read-write
conflicts when both transactions were SERIALIZABLE.

This seems like a subset of the issues which one might want to
address by making DDL statement behave in a more strictly MVCC
fashion. Does it make sense to pick those off one at a time, or
should something like this be done only in the context of an overall
plan to deal with all of it?

-Kevin



pgsql-hackers by date:

Previous
From: "Kevin Grittner"
Date:
Subject: Re: AutoVacuum starvation from sinval messages
Next
From: Tom Lane
Date:
Subject: Re: AutoVacuum starvation from sinval messages