Tom Lane wrote:
It looks to me like the problem is that AtPrepare_Locks invokes
LockTagIsTemp, and that goes and reads various system catalogs, which
can result in new entries in the LOCALLOCK hash table, which might
result in a bucket split in same, which would result in some entries
possibly being scanned twice by the hash_seq_search scan.
Not sure about good fix, except that AtPrepare is probably a really
bad time to be doing fresh catalog searches.
Yep.
A simple fix would be to do the scan in two phases, searching for temp
tables in the first phase, and writing the 2PC records in the second.
We'd still be doing the catalog searches in the 1st phase, and might
therefore split buckets and see some entries twice, but it wouldn't lead
to duplicate 2PC records.
Also, we have a generic issue that making fresh entries in a hashtable
might result in a concurrent hash_seq_search scan visiting existing
entries more than once; that's definitely not something any of the
existing callers are thinking about.
Ouch. Note that we can also miss some entries altogether, which is
probably even worse.
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com
---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster