|
37 | 37 | *
|
38 | 38 | *
|
39 | 39 | * IDENTIFICATION
|
40 |
| - * $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.21 2005/10/15 02:49:23 momjian Exp $ |
| 40 | + * $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.22 2005/12/08 19:19:22 tgl Exp $ |
41 | 41 | *
|
42 | 42 | *-------------------------------------------------------------------------
|
43 | 43 | */
|
|
51 | 51 | #include"miscadmin.h"
|
52 | 52 | #include"postmaster/bgwriter.h"
|
53 | 53 | #include"storage/bufmgr.h"
|
| 54 | +#include"storage/fd.h" |
54 | 55 | #include"storage/freespace.h"
|
55 | 56 | #include"storage/ipc.h"
|
56 | 57 | #include"storage/pmsignal.h"
|
57 | 58 | #include"storage/smgr.h"
|
58 | 59 | #include"tcop/tcopprot.h"
|
59 | 60 | #include"utils/guc.h"
|
60 | 61 | #include"utils/memutils.h"
|
| 62 | +#include"utils/resowner.h" |
61 | 63 |
|
62 | 64 |
|
63 | 65 | /*----------
|
@@ -208,6 +210,12 @@ BackgroundWriterMain(void)
|
208 | 210 | */
|
209 | 211 | last_checkpoint_time=time(NULL);
|
210 | 212 |
|
| 213 | +/* |
| 214 | + * Create a resource owner to keep track of our resources (currently |
| 215 | + * only buffer pins). |
| 216 | + */ |
| 217 | +CurrentResourceOwner=ResourceOwnerCreate(NULL,"Background Writer"); |
| 218 | + |
211 | 219 | /*
|
212 | 220 | * Create a memory context that we will do all our work in. We do this so
|
213 | 221 | * that we can reset the context during error recovery and thereby avoid
|
@@ -240,11 +248,18 @@ BackgroundWriterMain(void)
|
240 | 248 | /*
|
241 | 249 | * These operations are really just a minimal subset of
|
242 | 250 | * AbortTransaction().We don't have very many resources to worry
|
243 |
| - * about in bgwriter, but we do have LWLocksandbuffers. |
| 251 | + * about in bgwriter, but we do have LWLocks, buffers,andtemp files. |
244 | 252 | */
|
245 | 253 | LWLockReleaseAll();
|
246 | 254 | AbortBufferIO();
|
247 | 255 | UnlockBuffers();
|
| 256 | +/* buffer pins are released here: */ |
| 257 | +ResourceOwnerRelease(CurrentResourceOwner, |
| 258 | +RESOURCE_RELEASE_BEFORE_LOCKS, |
| 259 | + false, true); |
| 260 | +/* we needn't bother with the other ResourceOwnerRelease phases */ |
| 261 | +AtEOXact_Buffers(false); |
| 262 | +AtEOXact_Files(); |
248 | 263 |
|
249 | 264 | /* Warn any waiting backends that the checkpoint failed. */
|
250 | 265 | if (ckpt_active)
|
|