|
37 | 37 | *
|
38 | 38 | *
|
39 | 39 | * IDENTIFICATION
|
40 |
| - * $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.73 2010/08/12 23:24:54 rhaas Exp $ |
| 40 | + * $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.74 2010/08/30 14:16:48 sriggs Exp $ |
41 | 41 | *
|
42 | 42 | *-------------------------------------------------------------------------
|
43 | 43 | */
|
@@ -156,6 +156,7 @@ static intKnownAssignedXidsGet(TransactionId *xarray, TransactionId xmax);
|
156 | 156 | staticintKnownAssignedXidsGetAndSetXmin(TransactionId*xarray,
|
157 | 157 | TransactionId*xmin,
|
158 | 158 | TransactionIdxmax);
|
| 159 | +staticintKnownAssignedXidsGetOldestXmin(void); |
159 | 160 | staticvoidKnownAssignedXidsDisplay(inttrace_level);
|
160 | 161 |
|
161 | 162 | /*
|
@@ -1112,6 +1113,18 @@ GetOldestXmin(bool allDbs, bool ignoreVacuum)
|
1112 | 1113 | }
|
1113 | 1114 | }
|
1114 | 1115 |
|
| 1116 | +if (RecoveryInProgress()) |
| 1117 | +{ |
| 1118 | +/* |
| 1119 | + * Check to see whether KnownAssignedXids contains an xid value |
| 1120 | + * older than the main procarray. |
| 1121 | + */ |
| 1122 | +TransactionIdkaxmin=KnownAssignedXidsGetOldestXmin(); |
| 1123 | +if (TransactionIdIsNormal(kaxmin)&& |
| 1124 | +TransactionIdPrecedes(kaxmin,result)) |
| 1125 | +result=kaxmin; |
| 1126 | +} |
| 1127 | + |
1115 | 1128 | LWLockRelease(ProcArrayLock);
|
1116 | 1129 |
|
1117 | 1130 | /*
|
@@ -3015,6 +3028,33 @@ KnownAssignedXidsGetAndSetXmin(TransactionId *xarray, TransactionId *xmin,
|
3015 | 3028 | returncount;
|
3016 | 3029 | }
|
3017 | 3030 |
|
| 3031 | +staticint |
| 3032 | +KnownAssignedXidsGetOldestXmin(void) |
| 3033 | +{ |
| 3034 | +/* use volatile pointer to prevent code rearrangement */ |
| 3035 | +volatileProcArrayStruct*pArray=procArray; |
| 3036 | +inthead, |
| 3037 | +tail; |
| 3038 | +inti; |
| 3039 | + |
| 3040 | +/* |
| 3041 | + * Fetch head just once, since it may change while we loop. |
| 3042 | + */ |
| 3043 | +SpinLockAcquire(&pArray->known_assigned_xids_lck); |
| 3044 | +tail=pArray->tailKnownAssignedXids; |
| 3045 | +head=pArray->headKnownAssignedXids; |
| 3046 | +SpinLockRelease(&pArray->known_assigned_xids_lck); |
| 3047 | + |
| 3048 | +for (i=tail;i<head;i++) |
| 3049 | +{ |
| 3050 | +/* Skip any gaps in the array */ |
| 3051 | +if (KnownAssignedXidsValid[i]) |
| 3052 | +returnKnownAssignedXids[i]; |
| 3053 | +} |
| 3054 | + |
| 3055 | +returnInvalidTransactionId; |
| 3056 | +} |
| 3057 | + |
3018 | 3058 | /*
|
3019 | 3059 | * Display KnownAssignedXids to provide debug trail
|
3020 | 3060 | *
|
|