pgsql: Fix dynahash.c to suppress hash bucket splits while a

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix dynahash.c to suppress hash bucket splits while a
Date: 2007-04-26 23:25:30
Message-ID: 20070426232530.94AA99FBFCF@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Log Message:
-----------
Fix dynahash.c to suppress hash bucket splits while a hash_seq_search() scan
is in progress on the same hashtable. This seems the least invasive way to
fix the recently-recognized problem that a split could cause the scan to
visit entries twice or (with much lower probability) miss them entirely.
The only field-reported problem caused by this is the "failed to re-find
shared lock object" PANIC in COMMIT PREPARED reported by Michel Dorochevsky,
which was caused by multiply visited entries. However, it seems certain
that mdsync() is vulnerable to missing required fsync's due to missed
entries, and I am fearful that RelationCacheInitializePhase2() might be at
risk as well. Because of that and the generalized hazard presented by this
bug, back-patch all the supported branches.

Along the way, fix pg_prepared_statement() and pg_cursor() to not assume
that the hashtables they are examining will stay static between calls.
This is risky regardless of the newly noted dynahash problem, because
hash_seq_search() has never promised to cope with deletion of table entries
other than the just-returned one. There may be no bug here because the only
supported way to call these functions is via ExecMakeTableFunctionResult()
which will cycle them to completion before doing anything very interesting,
but it seems best to get rid of the assumption. This affects 8.2 and HEAD
only, since those functions weren't there earlier.

Tags:
----
REL8_0_STABLE

Modified Files:
--------------
pgsql/src/backend/access/transam:
xact.c (r1.195.4.1 -> r1.195.4.2)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/transam/xact.c.diff?r1=1.195.4.1&r2=1.195.4.2)
pgsql/src/backend/executor:
nodeSubplan.c (r1.66 -> r1.66.4.1)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/nodeSubplan.c.diff?r1=1.66&r2=1.66.4.1)
pgsql/src/backend/storage/smgr:
md.c (r1.114.4.1 -> r1.114.4.2)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/storage/smgr/md.c.diff?r1=1.114.4.1&r2=1.114.4.2)
pgsql/src/backend/utils/hash:
dynahash.c (r1.58.4.1 -> r1.58.4.2)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/hash/dynahash.c.diff?r1=1.58.4.1&r2=1.58.4.2)
pgsql/src/include/nodes:
execnodes.h (r1.122 -> r1.122.4.1)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/nodes/execnodes.h.diff?r1=1.122&r2=1.122.4.1)
pgsql/src/include/utils:
hsearch.h (r1.34.4.1 -> r1.34.4.2)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/utils/hsearch.h.diff?r1=1.34.4.1&r2=1.34.4.2)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2007-04-26 23:25:41 pgsql: Fix dynahash.c to suppress hash bucket splits while a
Previous Message Tom Lane 2007-04-26 23:25:09 pgsql: Fix dynahash.c to suppress hash bucket splits while a