Re: BUG #3245: PANIC: failed to re-find shared loc k o b j ect - Mailing list pgsql-bugs

From Heikki Linnakangas
Subject Re: BUG #3245: PANIC: failed to re-find shared loc k o b j ect
Date
Msg-id 462DEF46.9000302@enterprisedb.com
Whole thread Raw
In response to Re: BUG #3245: PANIC: failed to re-find shared loc k o b j ect  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BUG #3245: PANIC: failed to re-find shared loc k o b j ect
List pgsql-bugs
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

pgsql-bugs by date:

Previous
From: Michael Meskes
Date:
Subject: Re: [HACKERS] BUG #3244: problem with PREPARE
Next
From: Magnus Hagander
Date:
Subject: Re: BUG #3242: FATAL: could not unlock semaphore: error code 298