|
7 | 7 | * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
8 | 8 | * Portions Copyright (c) 1994, Regents of the University of California
|
9 | 9 | *
|
10 |
| - * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.86.2.3 2003/01/21 19:51:42 tgl Exp $ |
| 10 | + * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.86.2.4 2004/08/11 04:09:12 tgl Exp $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
@@ -2945,6 +2945,15 @@ CreateCheckPoint(bool shutdown, bool force)
|
2945 | 2945 | checkPoint.ThisStartUpID = ThisStartUpID;
|
2946 | 2946 | checkPoint.time = time(NULL);
|
2947 | 2947 |
|
| 2948 | + /* |
| 2949 | + * We must hold CheckpointStartLock while determining the checkpoint |
| 2950 | + * REDO pointer. This ensures that any concurrent transaction commits |
| 2951 | + * will be either not yet logged, or logged and recorded in pg_clog. |
| 2952 | + * See notes in RecordTransactionCommit(). |
| 2953 | + */ |
| 2954 | + LWLockAcquire(CheckpointStartLock, LW_EXCLUSIVE); |
| 2955 | + |
| 2956 | + /* And we need WALInsertLock too */ |
2948 | 2957 | LWLockAcquire(WALInsertLock, LW_EXCLUSIVE);
|
2949 | 2958 |
|
2950 | 2959 | /*
|
@@ -2976,6 +2985,7 @@ CreateCheckPoint(bool shutdown, bool force)
|
2976 | 2985 | ControlFile->checkPointCopy.redo.xrecoff)
|
2977 | 2986 | {
|
2978 | 2987 | LWLockRelease(WALInsertLock);
|
| 2988 | + LWLockRelease(CheckpointStartLock); |
2979 | 2989 | LWLockRelease(CheckpointLock);
|
2980 | 2990 | END_CRIT_SECTION();
|
2981 | 2991 | return;
|
@@ -3035,11 +3045,13 @@ CreateCheckPoint(bool shutdown, bool force)
|
3035 | 3045 | #endif
|
3036 | 3046 |
|
3037 | 3047 | /*
|
3038 |
| - * Now we can release insert lock, allowing other xacts to proceed |
3039 |
| - * even while we are flushing disk buffers. |
| 3048 | + * Now we can release insert lock and checkpoint start lock, allowing |
| 3049 | + * other xacts to proceed even while we are flushing disk buffers. |
3040 | 3050 | */
|
3041 | 3051 | LWLockRelease(WALInsertLock);
|
3042 | 3052 |
|
| 3053 | + LWLockRelease(CheckpointStartLock); |
| 3054 | + |
3043 | 3055 | LWLockAcquire(XidGenLock, LW_SHARED);
|
3044 | 3056 | checkPoint.nextXid = ShmemVariableCache->nextXid;
|
3045 | 3057 | LWLockRelease(XidGenLock);
|
|
0 commit comments