Gaetano Mendola <mendola@bigfoot.com> writes:
> why SESSION 1 was unblocked ?
> ...
> Why that commit unblock the SESSION 1?
IMHO session 1 should have been unblocked in both cases as soon as
session 2's subtransaction failed. We have always made a practice
of releasing a transaction's locks immediately upon failure.
The reason it does not seem to act that way is that Alvaro's taken a
shortcut in WaitForTransaction: subtransactions do not take out a
separate transaction lock and so WaitForTransaction has to wait for the
top-level transaction. Your sub-COMMIT fails the outer transaction
(because the inner one is failed) and so the top transaction lock
releases at that point. In the sub-ABORT case the outer transaction
stays good and continues to hold its lock.
I've already suggested that this shortcut is no good, and now I'm
pretty sure of it ...
regards, tom lane