From: Kevin Grittner <Kevin.Grittner@wicourts.gov>
To: yamt@mwd.biglobe.ne.jp
To: pgsql-bugs@postgresql.org
Cc: drkp@csail.mit.edu
Subject: Re: BUG #5952: SetRWConflict assertion failure
Date: Sun, 27 Mar 2011 14:18:45 -0500
Message-ID: <4D8F4745020000250003BCFA@gw.wicourts.gov> (raw)
"YAMAMOTO Takashi" wrote:
> Description: SetRWConflict assertion failure
> SerializableXactHashLock relocking in CheckTargetForConflictsIn()
> seems racy to me.
You're right. The attached patch should fix the assertion you hit.
I will take a close look at the code above the patched area (for the
optimization to drop the predicate lock when we acquire a write
lock). Looking at it just now I'm wondering if it really is a safe
optimization in PostgreSQL. It was in the Cahill paper, but InnoDB
doesn't have subtransactions. I fear that we could give up the
SIReadLock within a subtransaction and then have problems if the
subtransaction rolls back, effectively discarding the write lock. I
suspect we need to do this only if we're not within a subtransaction.
Will follow up on that after further review.
Thanks!
-Kevin
Attachments:ssi-recheck-conflict-in-before-flagging.patch (application/octet-stream, 1.1K) download
*** a/src/backend/storage/lmgr/predicate.c
--- b/src/backend/storage/lmgr/predicate.c
***************
*** 3771,3777 **** CheckTargetForConflictsIn(PREDICATELOCKTARGETTAG *targettag)
LWLockRelease(SerializableXactHashLock);
LWLockAcquire(SerializableXactHashLock, LW_EXCLUSIVE);
! FlagRWConflict(sxact, (SERIALIZABLEXACT *) MySerializableXact);
LWLockRelease(SerializableXactHashLock);
LWLockAcquire(SerializableXactHashLock, LW_SHARED);
--- 3771,3789 ----
LWLockRelease(SerializableXactHashLock);
LWLockAcquire(SerializableXactHashLock, LW_EXCLUSIVE);
! /*
! * Re-check after getting exclusive lock because the other
! * transaction may have flagged a conflict.
! */
! if (!SxactIsRolledBack(sxact)
! && (!SxactIsCommitted(sxact)
! || TransactionIdPrecedes(GetTransactionSnapshot()->xmin,
! sxact->finishedBefore))
! && !RWConflictExists(sxact,
! (SERIALIZABLEXACT *) MySerializableXact))
! {
! FlagRWConflict(sxact, (SERIALIZABLEXACT *) MySerializableXact);
! }
LWLockRelease(SerializableXactHashLock);
LWLockAcquire(SerializableXactHashLock, LW_SHARED);
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: Kevin.Grittner@wicourts.gov, yamt@mwd.biglobe.ne.jp, drkp@csail.mit.edu
Subject: Re: BUG #5952: SetRWConflict assertion failure
In-Reply-To: <4D8F4745020000250003BCFA@gw.wicourts.gov>
References: <4D8F4745020000250003BCFA@gw.wicourts.gov>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox