postgresql/src
Robert Haas 76837c1507 Reduce use of heavyweight locking inside hash AM.
Avoid using LockPage(rel, 0, lockmode) to protect against changes to
the bucket mapping.  Instead, an exclusive buffer content lock is now
viewed as sufficient permission to modify the metapage, and a shared
buffer content lock is used when such modifications need to be
prevented.  This more relaxed locking regimen makes it possible that,
when we're busy getting a heavyweight bucket on the bucket we intend
to search or insert into, a bucket split might occur underneath us.
To compenate for that possibility, we use a loop-and-retry system:
release the metapage content lock, acquire the heavyweight lock on the
target bucket, and then reacquire the metapage content lock and check
that the bucket mapping has not changed.   Normally it hasn't, and
we're done.  But if by chance it has, we simply unlock the metapage,
release the heavyweight lock we acquired previously, lock the new
bucket, and loop around again.  Even in the worst case we cannot loop
very many times here, since we don't split the same bucket again until
we've split all the other buckets, and 2^N gets big pretty fast.

This results in greatly improved concurrency, because we're
effectively replacing two lwlock acquire-and-release cycles in
exclusive mode (on one of the lock manager locks) with a single
acquire-and-release cycle in shared mode (on the metapage buffer
content lock).  Testing shows that it's still not quite as good as
btree; for that, we'd probably have to find some way of getting rid
of the heavyweight bucket locks as well, which does not appear
straightforward.

Patch by me, review by Jeff Janes.
2012-06-26 06:56:10 -04:00
..
backend Reduce use of heavyweight locking inside hash AM. 2012-06-26 06:56:10 -04:00
bin Fix pg_upgrade, broken by the xlogid/segno -> 64-bit int refactoring. 2012-06-26 07:49:02 +03:00
include Tighten up includes in sinvaladt.h, twophase.h, proc.h 2012-06-25 18:40:40 -04:00
interfaces Replace int2/int4 in C code with int16/int32 2012-06-25 01:51:46 +03:00
makefiles
pl Run pgindent on 9.2 source tree in preparation for first 9.3 2012-06-10 15:20:04 -04:00
port Stamp HEAD as 9.3devel. 2012-06-13 20:03:02 -04:00
template
test Share RI trigger code between NO ACTION and RESTRICT cases. 2012-06-19 14:31:54 -04:00
timezone Run pgindent on 9.2 source tree in preparation for first 9.3 2012-06-10 15:20:04 -04:00
tools Remove 'for' loop perltidy argument, and move args to perltidyrc file. 2012-06-16 10:12:50 -04:00
tutorial
.gitignore
bcc32.mak
DEVELOPERS
Makefile
Makefile.global.in
Makefile.shlib
nls-global.mk
win32.mak