Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit fbc0d07

Browse files
committed
Partially roll back overenthusiastic SSI optimization.
When a regular lock is held, SSI can use that in lieu of a predicate lock to detect rw conflicts; but if the regular lock is being taken by a subtransaction, we can't assume that it'll commit, so releasing the parent transaction's lock in that case is a no-no. Kevin Grittner
1 parent 9c38bce commit fbc0d07

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/backend/storage/lmgr/predicate.c

+13-7
Original file line numberDiff line numberDiff line change
@@ -3638,14 +3638,20 @@ CheckTargetForConflictsIn(PREDICATELOCKTARGETTAG *targettag)
36383638
if (sxact == MySerializableXact)
36393639
{
36403640
/*
3641-
* If we're getting a write lock on the tuple, we don't need a
3642-
* predicate (SIREAD) lock. At this point our transaction already
3643-
* has an ExclusiveRowLock on the relation, so we are OK to drop
3644-
* the predicate lock on the tuple, if found, without fearing that
3645-
* another write against the tuple will occur before the MVCC
3646-
* information makes it to the buffer.
3641+
* If we're getting a write lock on the tuple and we're not in a
3642+
* subtransaction, we don't need a predicate (SIREAD) lock. We
3643+
* can't use this optimization within a subtransaction because
3644+
* the subtransaction could be rolled back, and we would be left
3645+
* without any lock at the top level.
3646+
*
3647+
* At this point our transaction already has an ExclusiveRowLock
3648+
* on the relation, so we are OK to drop the predicate lock on
3649+
* the tuple, if found, without fearing that another write
3650+
* against the tuple will occur before the MVCC information
3651+
* makes it to the buffer.
36473652
*/
3648-
if (GET_PREDICATELOCKTARGETTAG_OFFSET(*targettag))
3653+
if (!IsSubTransaction()
3654+
&& GET_PREDICATELOCKTARGETTAG_OFFSET(*targettag))
36493655
{
36503656
uint32 predlockhashcode;
36513657
PREDICATELOCKTARGET *rmtarget = NULL;

0 commit comments

Comments
 (0)