]> granicus.if.org Git - postgresql/commit
Implement sharable row-level locks, and use them for foreign key references
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 28 Apr 2005 21:47:18 +0000 (21:47 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 28 Apr 2005 21:47:18 +0000 (21:47 +0000)
commitbedb78d386a47fd66b6cda2040e0a5fb545ee371
tree0db0af8556ff82d94423e8e21362900afb18b7b6
parentd902e7d63ba2dc9cf0a1b051b2911b96831ef227
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.
55 files changed:
doc/src/sgml/mvcc.sgml
doc/src/sgml/ref/grant.sgml
doc/src/sgml/ref/lock.sgml
doc/src/sgml/ref/pg_resetxlog.sgml
doc/src/sgml/ref/select.sgml
doc/src/sgml/ref/select_into.sgml
doc/src/sgml/sql.sgml
doc/src/sgml/storage.sgml
src/backend/access/heap/heapam.c
src/backend/access/transam/Makefile
src/backend/access/transam/multixact.c [new file with mode: 0644]
src/backend/access/transam/xact.c
src/backend/access/transam/xlog.c
src/backend/catalog/index.c
src/backend/commands/portalcmds.c
src/backend/commands/trigger.c
src/backend/commands/vacuum.c
src/backend/executor/README
src/backend/executor/execMain.c
src/backend/executor/execUtils.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/nodes/outfuncs.c
src/backend/nodes/readfuncs.c
src/backend/optimizer/path/allpaths.c
src/backend/optimizer/plan/initsplan.c
src/backend/optimizer/plan/planner.c
src/backend/optimizer/prep/prepjointree.c
src/backend/optimizer/prep/preptlist.c
src/backend/parser/analyze.c
src/backend/parser/gram.y
src/backend/parser/parse_relation.c
src/backend/parser/parse_type.c
src/backend/rewrite/rewriteHandler.c
src/backend/storage/ipc/ipci.c
src/backend/storage/lmgr/lwlock.c
src/backend/tcop/utility.c
src/backend/utils/adt/ri_triggers.c
src/backend/utils/time/tqual.c
src/bin/initdb/initdb.c
src/bin/pg_controldata/pg_controldata.c
src/bin/pg_resetxlog/pg_resetxlog.c
src/include/access/heapam.h
src/include/access/htup.h
src/include/access/multixact.h [new file with mode: 0644]
src/include/access/xlog.h
src/include/c.h
src/include/catalog/pg_control.h
src/include/nodes/execnodes.h
src/include/nodes/parsenodes.h
src/include/parser/analyze.h
src/include/parser/parse_node.h
src/include/storage/bufpage.h
src/include/storage/lmgr.h
src/include/storage/lwlock.h