Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8816479

Browse files
committed
Need to reset local buffer pin counts, not only shared buffer pins,
before we attempt any file deletions in ShutdownPostgres. Per Tatsuo.
1 parent 1f41855 commit 8816479

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/backend/storage/buffer/localbuf.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/storage/buffer/localbuf.c,v 1.63 2005/03/04 20:21:06 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/storage/buffer/localbuf.c,v 1.64 2005/03/18 16:16:09 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -259,3 +259,17 @@ AtEOXact_LocalBuffers(bool isCommit)
259259
}
260260
#endif
261261
}
262+
263+
/*
264+
* AtProcExit_LocalBuffers - ensure we have dropped pins during backend exit.
265+
*
266+
* This is just like AtProcExit_Buffers, but for local buffers. We have
267+
* to drop pins to ensure that any attempt to drop temp files doesn't
268+
* fail in DropRelFileNodeBuffers.
269+
*/
270+
void
271+
AtProcExit_LocalBuffers(void)
272+
{
273+
/* just zero the refcounts ... */
274+
MemSet(LocalRefCount, 0, NLocBuffer * sizeof(*LocalRefCount));
275+
}

src/backend/utils/init/postinit.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.142 2005/03/18 05:24:13 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.143 2005/03/18 16:16:09 tgl Exp $
1212
*
1313
*
1414
*-------------------------------------------------------------------------
@@ -515,6 +515,7 @@ ShutdownPostgres(int code, Datum arg)
515515
*/
516516
LWLockReleaseAll();
517517
AtProcExit_Buffers();
518+
AtProcExit_LocalBuffers();
518519

519520
/*
520521
* In case a transaction is open, delete any files it created. This

src/include/storage/bufmgr.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/storage/bufmgr.h,v 1.90 2005/03/04 20:21:07 tgl Exp $
10+
* $PostgreSQL: pgsql/src/include/storage/bufmgr.h,v 1.91 2005/03/18 16:16:09 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -158,6 +158,7 @@ extern void BufferSync(void);
158158
extern void BgBufferSync(void);
159159

160160
extern void InitLocalBuffer(void);
161+
extern void AtProcExit_LocalBuffers(void);
161162

162163
/* in freelist.c */
163164
extern void StrategyHintVacuum(bool vacuum_active);

0 commit comments

Comments
 (0)