Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TyQFp-0004jU-Ej for pgsql-bugs@arkaria.postgresql.org; Thu, 24 Jan 2013 17:06:21 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TyQFo-0005hb-VR for pgsql-bugs@arkaria.postgresql.org; Thu, 24 Jan 2013 17:06:21 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TyQFo-0005hM-8a for pgsql-bugs@postgresql.org; Thu, 24 Jan 2013 17:06:20 +0000 Received: from moutng.kundenserver.de ([212.227.17.10]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TyQFm-00008b-5V for pgsql-bugs@postgresql.org; Thu, 24 Jan 2013 17:06:19 +0000 Received: from anarazel.de (p5DDC49C5.dip.t-dialin.net [93.220.73.197]) by mrelayeu.kundenserver.de (node=mreu4) with ESMTP (Nemesis) id 0Ls2t1-1V1chY0NyB-013yrZ; Thu, 24 Jan 2013 18:06:11 +0100 Received: by anarazel.de (Postfix, from userid 1000) id 433E11C0173; Thu, 24 Jan 2013 18:06:10 +0100 (CET) Date: Thu, 24 Jan 2013 18:06:10 +0100 From: Andres Freund To: Tom Lane Cc: Sandro Santilli , pgsql-bugs@postgresql.org Subject: Re: cache lookup failed from empty plpythonu function Message-ID: <20130124170610.GB8539@awork2.anarazel.de> References: <20130124140336.GJ3157@gnash> <20130124141751.GB21296@awork2.anarazel.de> <19721.1359045633@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <19721.1359045633@sss.pgh.pa.us> X-Provags-ID: V02:K0:eaoA+0UA07ILsOECsYWsgVKcdaHhePlNFC5lpwhTJzq ZZN3nDWYpXdH6iJpKEYqgB4RuxZvCB91Y3zoKpugZEbc83p7uX mQSGB/9jbZlVU7XK4txkj4nqYGaatOFXpfG18NN42MTpabnh0/ cI0zTMrDgID5hFlOY8eheR0aZ+brsad2VvC6UrCMNk+FysujWP XhPnwftDqfXkaJSeBHxhUMEX/K9OmYCxwUbX5aVN6CbqP4sPsz bnuzHK53elvB/VzOywXTV/pG7o3F5iORHLkoCZ+4tL99uU+SzF xV+FslznAyMf7oeGiYJ9GyFuSRfnDwNsDnX7kbBT/WQFIAg1QW w5dowd62Nma5dl2ts8SuxSpBqre/ur+S9lg3NNbju X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 2013-01-24 11:40:33 -0500, Tom Lane wrote: > Andres Freund writes: > > On 2013-01-24 15:03:36 +0100, Sandro Santilli wrote: > > ISTM the caching code for plpythonu trigger functions has been broken > > for some time. The bug seem to be that PLy_procedure_get looks up the > > function in a separate cache for trigger functions (PLy_trigger_cache) > > but still only uses the function oid for lookup. > > So the same function can be looked up for two tables and when the cached > > entry originally refers to the old table that has been dropped we see > > the above error. > > > The fix seems to be to make PLy_trigger_cache have a key of (reloid, > > fn_oid) instead of just fn_oid. > > If there's anything in either the cache entry itself or the function's > other persistent state that is dependent on which table it's attached > to, then yeah, obviously. But another conceivable solution would be to > not store any such information. > > In a quick look, it seems like the "PLyTypeInfo result" field might > depend on which table the trigger is attached to, so unless we can > get along without that, we'll need to expand the hash key. It looks to me like getting rid of that requirement would be too much code for something backbrancheable . Although I dislike seing code like /* If the pg_proc tuple has changed, it's not valid */ if (!(proc->fn_xmin == HeapTupleHeaderGetXmin(procTup->t_data) && ItemPointerEquals(&proc->fn_tid, &procTup->t_self))) return false; in a pl. I have to admit though, that I don't immediately know how I would prevent constant recompilation in a pl handler without such a hack. > Actually I'm wondering a bit why there are two hash tables at all. > Seems like one table with a hash key of (fnoid, reloid) could be > used, with the convention of reloid = 0 for non-trigger calls. Seems fine to me. Currently there seems no point in having two distinct hashes at all, given that they have exactly the same key and that trigger functions cannot be called plainly anyway. Unless somebody screams that will mean some stuff defined in plpython headers will change but that doesn't seem like a legitimate concern to me. Tom, any other committer: I am happy to provide a <= 9.1 version of the patch because plpython has been noticeably restructured in 9.1=>9.2, but I am not sure if that helps you at all. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs