1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-10 17:42:29 +03:00

Theses buffer leaks are caused by indexes that are kept open between

calls. Outside a transaction, the backend detects them as buffer
leaks; it sends a NOTICE, and frees them. This sometimes cause a
segmentation fault (at least on Linux). These indexes are initialized
on the first lo_read/lo_write/lo_tell call, and (normally) closed
on a lo_close call.  Thus the buffer leaks appear when lo direct
access functions are used, and not with lo_import/lo_export functions
(libpq version calls lo_close before ending the command, and the
backend version uses another path).

The included patches (against recent snapshot, and against 6.3.2)
cause indexes to be closed on transaction end (that is on explicit
'END' statment, or on command termination outside trasaction blocks),
thus preventing the buffer leaks while increasing performance inside
transactions. Some (all?) 'classic' memory leaks are also removed.

I hope it will be ok.

--- Pascal ANDRE, graduated from Ecole Centrale Paris andre@via.ecp.fr
This commit is contained in:
Bruce Momjian
1998-07-21 04:17:30 +00:00
parent 7702d7aa4b
commit e0058b6172
5 changed files with 96 additions and 9 deletions

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.21 1998/06/15 19:28:25 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.22 1998/07/21 04:17:23 momjian Exp $
*
* NOTES
* This should be moved to a more appropriate place. It is here
@@ -41,6 +41,8 @@
#include <storage/large_object.h>
#include <libpq/be-fsstubs.h>
/* [PA] is Pascal Andr<64> <andre@via.ecp.fr> */
/*#define FSDB 1*/
#define MAX_LOBJ_FDS 256
@@ -52,7 +54,6 @@ static GlobalMemory fscxt = NULL;
static int newLOfd(LargeObjectDesc *lobjCookie);
static void deleteLOfd(int fd);
/*****************************************************************************
* File Interfaces for Large Objects
*****************************************************************************/
@@ -367,6 +368,26 @@ lo_export(Oid lobjId, text *filename)
return 1;
}
/*
* lo_commit -
* prepares large objects for transaction commit [PA, 7/17/98]
*/
void
_lo_commit(void)
{
int i;
MemoryContext currentContext;
currentContext = MemoryContextSwitchTo((MemoryContext) fscxt);
for (i = 0; i < MAX_LOBJ_FDS; i++) {
if (cookies[i] != NULL) inv_cleanindex(cookies[i]);
}
MemoryContextSwitchTo(currentContext);
}
/*****************************************************************************
* Support routines for this file