3
3
* standby.c
4
4
* Misc functions used in Hot Standby mode.
5
5
*
6
- * InitRecoveryTransactionEnvironment()
7
- * ShutdownRecoveryTransactionEnvironment()
8
- *
9
- * ResolveRecoveryConflictWithVirtualXIDs()
10
- *
11
6
* All functions for handling RM_STANDBY_ID, which relate to
12
7
* AccessExclusiveLocks and starting snapshots for Hot Standby mode.
8
+ * Plus conflict recovery processing.
13
9
*
14
10
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
15
11
* Portions Copyright (c) 1994, Regents of the University of California
16
12
*
17
13
* IDENTIFICATION
18
- * $PostgreSQL: pgsql/src/backend/storage/ipc/standby.c,v 1.4 2010/01/14 11:08:02 sriggs Exp $
14
+ * $PostgreSQL: pgsql/src/backend/storage/ipc/standby.c,v 1.5 2010/01/16 10:05:50 sriggs Exp $
19
15
*
20
16
*-------------------------------------------------------------------------
21
17
*/
@@ -38,7 +34,7 @@ int vacuum_defer_cleanup_age;
38
34
static List * RecoveryLockList ;
39
35
40
36
static void ResolveRecoveryConflictWithVirtualXIDs (VirtualTransactionId * waitlist ,
41
- char * reason , int cancel_mode );
37
+ ProcSignalReason reason );
42
38
static void ResolveRecoveryConflictWithLock (Oid dbOid , Oid relOid );
43
39
static void LogCurrentRunningXacts (RunningTransactions CurrRunningXacts );
44
40
static void LogAccessExclusiveLocks (int nlocks , xl_standby_lock * locks );
@@ -162,17 +158,13 @@ WaitExceedsMaxStandbyDelay(void)
162
158
* recovery processing. Judgement has already been passed on it within
163
159
* a specific rmgr. Here we just issue the orders to the procs. The procs
164
160
* then throw the required error as instructed.
165
- *
166
- * We may ask for a specific cancel_mode, typically ERROR or FATAL.
167
161
*/
168
162
static void
169
163
ResolveRecoveryConflictWithVirtualXIDs (VirtualTransactionId * waitlist ,
170
- char * reason , int cancel_mode )
164
+ ProcSignalReason reason )
171
165
{
172
166
char waitactivitymsg [100 ];
173
167
174
- Assert (cancel_mode > 0 );
175
-
176
168
while (VirtualTransactionIdIsValid (* waitlist ))
177
169
{
178
170
long wait_s ;
@@ -206,12 +198,6 @@ ResolveRecoveryConflictWithVirtualXIDs(VirtualTransactionId *waitlist,
206
198
len = 100 ;
207
199
memcpy (waitactivitymsg , oldactivitymsg , len );
208
200
209
- ereport (trace_recovery (DEBUG5 ),
210
- (errmsg ("virtual transaction %u/%u is blocking %s" ,
211
- waitlist -> backendId ,
212
- waitlist -> localTransactionId ,
213
- reason )));
214
-
215
201
pgstat_report_waiting (true);
216
202
217
203
logged = true;
@@ -226,40 +212,14 @@ ResolveRecoveryConflictWithVirtualXIDs(VirtualTransactionId *waitlist,
226
212
* Now find out who to throw out of the balloon.
227
213
*/
228
214
Assert (VirtualTransactionIdIsValid (* waitlist ));
229
- pid = CancelVirtualTransaction (* waitlist , cancel_mode );
215
+ pid = CancelVirtualTransaction (* waitlist , reason );
230
216
217
+ /*
218
+ * Wait awhile for it to die so that we avoid flooding an
219
+ * unresponsive backend when system is heavily loaded.
220
+ */
231
221
if (pid != 0 )
232
- {
233
- /*
234
- * Startup process debug messages
235
- */
236
- switch (cancel_mode )
237
- {
238
- case CONFLICT_MODE_FATAL :
239
- elog (trace_recovery (DEBUG1 ),
240
- "recovery disconnects session with pid %ld because of conflict with %s" ,
241
- (long ) pid ,
242
- reason );
243
- break ;
244
- case CONFLICT_MODE_ERROR :
245
- elog (trace_recovery (DEBUG1 ),
246
- "recovery cancels virtual transaction %u/%u pid %ld because of conflict with %s" ,
247
- waitlist -> backendId ,
248
- waitlist -> localTransactionId ,
249
- (long ) pid ,
250
- reason );
251
- break ;
252
- default :
253
- /* No conflict pending, so fall through */
254
- break ;
255
- }
256
-
257
- /*
258
- * Wait awhile for it to die so that we avoid flooding an
259
- * unresponsive backend when system is heavily loaded.
260
- */
261
222
pg_usleep (5000 );
262
- }
263
223
}
264
224
}
265
225
@@ -285,8 +245,7 @@ ResolveRecoveryConflictWithSnapshot(TransactionId latestRemovedXid)
285
245
true);
286
246
287
247
ResolveRecoveryConflictWithVirtualXIDs (backends ,
288
- "snapshot conflict" ,
289
- CONFLICT_MODE_ERROR );
248
+ PROCSIG_RECOVERY_CONFLICT_SNAPSHOT );
290
249
}
291
250
292
251
void
@@ -317,8 +276,7 @@ ResolveRecoveryConflictWithTablespace(Oid tsid)
317
276
InvalidOid ,
318
277
false);
319
278
ResolveRecoveryConflictWithVirtualXIDs (temp_file_users ,
320
- "drop tablespace" ,
321
- CONFLICT_MODE_ERROR );
279
+ PROCSIG_RECOVERY_CONFLICT_TABLESPACE );
322
280
}
323
281
324
282
void
@@ -379,8 +337,7 @@ ResolveRecoveryConflictWithLock(Oid dbOid, Oid relOid)
379
337
}
380
338
381
339
ResolveRecoveryConflictWithVirtualXIDs (backends ,
382
- "exclusive lock" ,
383
- CONFLICT_MODE_ERROR );
340
+ PROCSIG_RECOVERY_CONFLICT_LOCK );
384
341
385
342
if (LockAcquireExtended (& locktag , AccessExclusiveLock , true, true, false)
386
343
!= LOCKACQUIRE_NOT_AVAIL )
0 commit comments