diff options
-rw-r--r-- | src/backend/postmaster/bgwriter.c | 19 | ||||
-rw-r--r-- | src/backend/utils/resowner/resowner.c | 8 |
2 files changed, 21 insertions, 6 deletions
diff --git a/src/backend/postmaster/bgwriter.c b/src/backend/postmaster/bgwriter.c index 353d43b8eb..8657d1ee31 100644 --- a/src/backend/postmaster/bgwriter.c +++ b/src/backend/postmaster/bgwriter.c @@ -37,7 +37,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.13.4.2 2005/09/12 22:20:30 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.13.4.3 2005/12/08 19:19:45 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -51,6 +51,7 @@ #include "miscadmin.h" #include "postmaster/bgwriter.h" #include "storage/bufmgr.h" +#include "storage/fd.h" #include "storage/freespace.h" #include "storage/ipc.h" #include "storage/pmsignal.h" @@ -58,6 +59,7 @@ #include "tcop/tcopprot.h" #include "utils/guc.h" #include "utils/memutils.h" +#include "utils/resowner.h" /*---------- @@ -204,6 +206,12 @@ BackgroundWriterMain(void) last_checkpoint_time = time(NULL); /* + * Create a resource owner to keep track of our resources (currently + * only buffer pins). + */ + CurrentResourceOwner = ResourceOwnerCreate(NULL, "Background Writer"); + + /* * Create a memory context that we will do all our work in. We do this * so that we can reset the context during error recovery and thereby * avoid possible memory leaks. Formerly this code just ran in @@ -235,11 +243,18 @@ BackgroundWriterMain(void) /* * These operations are really just a minimal subset of * AbortTransaction(). We don't have very many resources to worry - * about in bgwriter, but we do have LWLocks and buffers. + * about in bgwriter, but we do have LWLocks, buffers, and temp files. */ LWLockReleaseAll(); AbortBufferIO(); UnlockBuffers(); + /* buffer pins are released here: */ + ResourceOwnerRelease(CurrentResourceOwner, + RESOURCE_RELEASE_BEFORE_LOCKS, + false, true); + /* we needn't bother with the other ResourceOwnerRelease phases */ + AtEOXact_Buffers(false); + AtEOXact_Files(); /* Warn any waiting backends that the checkpoint failed. */ if (ckpt_active) diff --git a/src/backend/utils/resowner/resowner.c b/src/backend/utils/resowner/resowner.c index 5f1f99f703..97024064a0 100644 --- a/src/backend/utils/resowner/resowner.c +++ b/src/backend/utils/resowner/resowner.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/resowner/resowner.c,v 1.9 2004/12/31 22:02:50 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/utils/resowner/resowner.c,v 1.9.4.1 2005/12/08 19:19:45 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -455,7 +455,7 @@ UnregisterResourceReleaseCallback(ResourceReleaseCallback callback, void *arg) * of memory, it's critical to do so *before* acquiring the resource. * * We allow the case owner == NULL because the bufmgr is sometimes invoked - * outside any transaction (for example, in the bgwriter). + * outside any transaction (for example, during WAL recovery). */ void ResourceOwnerEnlargeBuffers(ResourceOwner owner) @@ -488,7 +488,7 @@ ResourceOwnerEnlargeBuffers(ResourceOwner owner) * Caller must have previously done ResourceOwnerEnlargeBuffers() * * We allow the case owner == NULL because the bufmgr is sometimes invoked - * outside any transaction (for example, in the bgwriter). + * outside any transaction (for example, during WAL recovery). */ void ResourceOwnerRememberBuffer(ResourceOwner owner, Buffer buffer) @@ -505,7 +505,7 @@ ResourceOwnerRememberBuffer(ResourceOwner owner, Buffer buffer) * Forget that a buffer pin is owned by a ResourceOwner * * We allow the case owner == NULL because the bufmgr is sometimes invoked - * outside any transaction (for example, in the bgwriter). + * outside any transaction (for example, during WAL recovery). */ void ResourceOwnerForgetBuffer(ResourceOwner owner, Buffer buffer) |