|
7 | 7 | * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
8 | 8 | * Portions Copyright (c) 1994, Regents of the University of California
|
9 | 9 | *
|
10 |
| - * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.142 2004/05/21 16:08:46 tgl Exp $ |
| 10 | + * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.143 2004/05/27 17:12:42 tgl Exp $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
@@ -166,9 +166,10 @@ XLogRecPtr ProcLastRecEnd = {0, 0};
|
166 | 166 | * XLogCtl->Insert.RedoRecPtr, whenever we can safely do so (ie, when we
|
167 | 167 | * hold the Insert lock). See XLogInsert for details. We are also allowed
|
168 | 168 | * to update from XLogCtl->Insert.RedoRecPtr if we hold the info_lck;
|
169 |
| - * see GetRedoRecPtr. |
| 169 | + * see GetRedoRecPtr. A freshly spawned backend obtains the value during |
| 170 | + * InitXLOGAccess. |
170 | 171 | */
|
171 |
| -NON_EXEC_STATIC XLogRecPtr RedoRecPtr; |
| 172 | +static XLogRecPtr RedoRecPtr; |
172 | 173 |
|
173 | 174 | /*----------
|
174 | 175 | * Shared-memory data structures for XLOG control
|
@@ -280,10 +281,6 @@ typedef struct XLogCtlData
|
280 | 281 | uint32 XLogCacheBlck; /* highest allocated xlog buffer index */
|
281 | 282 | StartUpID ThisStartUpID;
|
282 | 283 |
|
283 |
| - /* This value is not protected by *any* lock... */ |
284 |
| - /* see SetSavedRedoRecPtr/GetSavedRedoRecPtr */ |
285 |
| - XLogRecPtr SavedRedoRecPtr; |
286 |
| - |
287 | 284 | slock_t info_lck; /* locks shared LogwrtRqst/LogwrtResult */
|
288 | 285 | } XLogCtlData;
|
289 | 286 |
|
@@ -2893,8 +2890,7 @@ StartupXLOG(void)
|
2893 | 2890 | else
|
2894 | 2891 | ThisStartUpID = checkPoint.ThisStartUpID;
|
2895 | 2892 |
|
2896 |
| - RedoRecPtr = XLogCtl->Insert.RedoRecPtr = |
2897 |
| - XLogCtl->SavedRedoRecPtr = checkPoint.redo; |
| 2893 | + RedoRecPtr = XLogCtl->Insert.RedoRecPtr = checkPoint.redo; |
2898 | 2894 |
|
2899 | 2895 | if (XLByteLT(RecPtr, checkPoint.redo))
|
2900 | 2896 | ereport(PANIC,
|
@@ -3251,35 +3247,22 @@ ReadCheckpointRecord(XLogRecPtr RecPtr,
|
3251 | 3247 | }
|
3252 | 3248 |
|
3253 | 3249 | /*
|
3254 |
| - * Postmaster uses this to initialize ThisStartUpID & RedoRecPtr from |
3255 |
| - * XLogCtlData located in shmem after successful startup. |
| 3250 | + * This must be called during startup of a backend process, except that |
| 3251 | + * it need not be called in a standalone backend (which does StartupXLOG |
| 3252 | + * instead). We need to initialize the local copies of ThisStartUpID and |
| 3253 | + * RedoRecPtr. |
| 3254 | + * |
| 3255 | + * Note: before Postgres 7.5, we went to some effort to keep the postmaster |
| 3256 | + * process's copies of ThisStartUpID and RedoRecPtr valid too. This was |
| 3257 | + * unnecessary however, since the postmaster itself never touches XLOG anyway. |
3256 | 3258 | */
|
3257 | 3259 | void
|
3258 |
| -SetThisStartUpID(void) |
| 3260 | +InitXLOGAccess(void) |
3259 | 3261 | {
|
| 3262 | + /* ThisStartUpID doesn't change so we need no lock to copy it */ |
3260 | 3263 | ThisStartUpID = XLogCtl->ThisStartUpID;
|
3261 |
| - RedoRecPtr = XLogCtl->SavedRedoRecPtr; |
3262 |
| -} |
3263 |
| - |
3264 |
| -/* |
3265 |
| - * CheckPoint process called by postmaster saves copy of new RedoRecPtr |
3266 |
| - * in shmem (using SetSavedRedoRecPtr). When checkpointer completes, |
3267 |
| - * postmaster calls GetSavedRedoRecPtr to update its own copy of RedoRecPtr, |
3268 |
| - * so that subsequently-spawned backends will start out with a reasonably |
3269 |
| - * up-to-date local RedoRecPtr. Since these operations are not protected by |
3270 |
| - * any lock and copying an XLogRecPtr isn't atomic, it's unsafe to use either |
3271 |
| - * of these routines at other times! |
3272 |
| - */ |
3273 |
| -void |
3274 |
| -SetSavedRedoRecPtr(void) |
3275 |
| -{ |
3276 |
| - XLogCtl->SavedRedoRecPtr = RedoRecPtr; |
3277 |
| -} |
3278 |
| - |
3279 |
| -void |
3280 |
| -GetSavedRedoRecPtr(void) |
3281 |
| -{ |
3282 |
| - RedoRecPtr = XLogCtl->SavedRedoRecPtr; |
| 3264 | + /* Use GetRedoRecPtr to copy the RedoRecPtr safely */ |
| 3265 | + (void) GetRedoRecPtr(); |
3283 | 3266 | }
|
3284 | 3267 |
|
3285 | 3268 | /*
|
|
0 commit comments