Skip to content

Commit 42ad25f

Browse files
committed
init_fcache was being careless about using SearchSysCacheTuple result
over multiple lookups --- it should use SearchSysCacheTupleCopy instead. This accounts for rare failures like 'init_fcache: null probin for procedure 481' when running concurrently with a VACUUM.
1 parent e57e991 commit 42ad25f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/backend/utils/cache/fcache.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.31 2000/05/28 17:56:06 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.32 2000/06/06 17:44:25 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
1515
#include "postgres.h"
1616

17+
#include "access/heapam.h"
1718
#include "catalog/pg_language.h"
1819
#include "catalog/pg_proc.h"
1920
#include "catalog/pg_type.h"
@@ -77,11 +78,13 @@ init_fcache(Oid foid,
7778

7879
/* ----------------
7980
* get the procedure tuple corresponding to the given functionOid
81+
*
82+
* NB: use SearchSysCacheTupleCopy to ensure tuple lives long enough
8083
* ----------------
8184
*/
82-
procedureTuple = SearchSysCacheTuple(PROCOID,
83-
ObjectIdGetDatum(foid),
84-
0, 0, 0);
85+
procedureTuple = SearchSysCacheTupleCopy(PROCOID,
86+
ObjectIdGetDatum(foid),
87+
0, 0, 0);
8588

8689
if (!HeapTupleIsValid(procedureTuple))
8790
elog(ERROR, "init_fcache: Cache lookup failed for procedure %u",
@@ -245,6 +248,8 @@ init_fcache(Oid foid,
245248
else
246249
retval->func.fn_addr = (PGFunction) NULL;
247250

251+
heap_freetuple(procedureTuple);
252+
248253
return retval;
249254
}
250255

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy