Question about SSI, subxacts, and aborted read-only xacts - Mailing list pgsql-hackers

From Jeff Davis
Subject Question about SSI, subxacts, and aborted read-only xacts
Date
Msg-id 1347129296.9572.24.camel@jdavis
Whole thread Raw
Responses Re: Question about SSI, subxacts, and aborted read-only xacts  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
Re: Question about SSI, subxacts, and aborted read-only xacts  (Dan Ports <drkp@csail.mit.edu>)
List pgsql-hackers
This question comes about after reading the VLDB paper "Serializable
Snapshot Isolation in PostgreSQL".

We release predicate locks after a transaction abort, but not after a
subtransaction abort. The paper says that the reason is:

"We do not drop SIREAD locks acquired during a subtransaction if the
subtransaction is aborted (i.e. all SIREAD locks belong to the top-level
transaction). This is because data read during the subtransaction may
have been reported to the user or otherwise externalized." (section
7.3).

But that doesn't make sense to me, because that reasoning would also
apply to top-level transactions that are aborted, but we release the
SIREAD locks for those.

In other words, this introduces an inconsistency between:
 BEGIN ISOLATION LEVEL SERIALIZABLE; SAVEPOINT s1; ... ROLLBACK TO s1; COMMIT;

and:
 BEGIN ISOLATION LEVEL SERIALIZABLE; ... ROLLBACK;

I'm not suggesting this is a correctness problem: holding SIREAD locks
for longer never causes incorrect results. But it does seem a little
inconsistent.

For top-level transactions, I don't think it's possible to preserve
SIREAD locks after an abort, because we rely on aborts to alleviate
conflicts (and when using 2PC, we may need to abort a read-only
transaction to correct the situation). So it seems like users must not
rely on any answers they get from a transaction (or subtransaction)
unless it commits.

Does that make sense?

If so, I think we need a documentation update. The serializable
isolation level docs don't quite make it clear that serializability only
applies to transactions that commit. It might not be obvious to a user
that there's a difference between commit and abort for a RO transaction.
I think that, in S2PL, serializability applies even to aborted
transactions (though I haven't spent much time thinking about it), so
users accustomed to other truly-serializable implementations might be
surprised.

Regards,Jeff Davis






pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: patch: disable bypass of expand variadic for "ANY" variable function, format_array function for formatting with params in array
Next
From: Andrew Dunstan
Date:
Subject: Re: build farm machine using mixed results