diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-04-28 21:47:18 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-04-28 21:47:18 +0000 |
commit | bedb78d386a47fd66b6cda2040e0a5fb545ee371 (patch) | |
tree | 0db0af8556ff82d94423e8e21362900afb18b7b6 /src/backend/access/transam/xact.c | |
parent | d902e7d63ba2dc9cf0a1b051b2911b96831ef227 (diff) | |
download | postgresql-bedb78d386a47fd66b6cda2040e0a5fb545ee371.tar.gz postgresql-bedb78d386a47fd66b6cda2040e0a5fb545ee371.zip |
Implement sharable row-level locks, and use them for foreign key references
to eliminate unnecessary deadlocks. This commit adds SELECT ... FOR SHARE
paralleling SELECT ... FOR UPDATE. The implementation uses a new SLRU
data structure (managed much like pg_subtrans) to represent multiple-
transaction-ID sets. When more than one transaction is holding a shared
lock on a particular row, we create a MultiXactId representing that set
of transactions and store its ID in the row's XMAX. This scheme allows
an effectively unlimited number of row locks, just as we did before,
while not costing any extra overhead except when a shared lock actually
has to be shared. Still TODO: use the regular lock manager to control
the grant order when multiple backends are waiting for a row lock.
Alvaro Herrera and Tom Lane.
Diffstat (limited to 'src/backend/access/transam/xact.c')
-rw-r--r-- | src/backend/access/transam/xact.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 4d896ef551d..a318db61343 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.199 2005/04/11 19:51:14 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.200 2005/04/28 21:47:10 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -20,6 +20,7 @@ #include <time.h> #include <unistd.h> +#include "access/multixact.h" #include "access/subtrans.h" #include "access/xact.h" #include "catalog/heap.h" @@ -1565,6 +1566,8 @@ CommitTransaction(void) */ smgrDoPendingDeletes(true); + AtEOXact_MultiXact(); + ResourceOwnerRelease(TopTransactionResourceOwner, RESOURCE_RELEASE_LOCKS, true, true); @@ -1710,6 +1713,7 @@ AbortTransaction(void) AtEOXact_Buffers(false); AtEOXact_Inval(false); smgrDoPendingDeletes(false); + AtEOXact_MultiXact(); ResourceOwnerRelease(TopTransactionResourceOwner, RESOURCE_RELEASE_LOCKS, false, true); @@ -3622,9 +3626,9 @@ static void ShowTransactionState(const char *str) { /* skip work if message will definitely not be printed */ - if (log_min_messages <= DEBUG2 || client_min_messages <= DEBUG2) + if (log_min_messages <= DEBUG3 || client_min_messages <= DEBUG3) { - elog(DEBUG2, "%s", str); + elog(DEBUG3, "%s", str); ShowTransactionStateRec(CurrentTransactionState); } } @@ -3640,7 +3644,7 @@ ShowTransactionStateRec(TransactionState s) ShowTransactionStateRec(s->parent); /* use ereport to suppress computation if msg will not be printed */ - ereport(DEBUG2, + ereport(DEBUG3, (errmsg_internal("name: %s; blockState: %13s; state: %7s, xid/subid/cid: %u/%u/%u, nestlvl: %d, children: %s", PointerIsValid(s->name) ? s->name : "unnamed", BlockStateAsString(s->blockState), |