On Wed, 2009-09-23 at 12:07 +0300, Heikki Linnakangas wrote:
> we need be careful to avoid putting any extra work into the normal
> recovery path. Otherwise bugs in hot standby related code can cause
> crash recovery to fail.

Re-checked code and found a couple of additional places that needed
tests 
        if (InHotStandby)

-- 
 Simon Riggs           www.2ndQuadrant.com
diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c
index bef0df1..b14d90a 100644
--- a/src/backend/commands/tablespace.c
+++ b/src/backend/commands/tablespace.c
@@ -1345,40 +1345,48 @@ tblspc_redo(XLogRecPtr lsn, XLogRecord *record)
 		{
 			VirtualTransactionId *temp_file_users;
 
-			/*
-			 * Standby users may be currently using this tablespace for
-			 * for their temporary files. We only care about current
-			 * users because temp_tablespace parameter will just ignore
-			 * tablespaces that no longer exist.
-			 *
-			 * Ask everybody to cancel their queries immediately so
-			 * we can ensure no temp files remain and we can remove the
-			 * tablespace. Nuke the entire site from orbit, it's the only
-			 * way to be sure.
-			 *
-			 * XXX: We could work out the pids of active backends
-			 * using this tablespace by examining the temp filenames in the
-			 * directory. We would then convert the pids into VirtualXIDs
-			 * before attempting to cancel them.
-			 *
-			 * We don't wait for commit because drop tablespace is
-			 * non-transactional.
-			 */
-			temp_file_users = GetConflictingVirtualXIDs(InvalidTransactionId,
-														InvalidOid,
-														false);
-			ResolveRecoveryConflictWithVirtualXIDs(temp_file_users,
-													"drop tablespace",
-													CONFLICT_MODE_ERROR_IF_NOT_IDLE,
-													InvalidXLogRecPtr);
+			if (InHotStandby)
+			{
+				/*
+				 * Standby users may be currently using this tablespace for
+				 * for their temporary files. We only care about current
+				 * users because temp_tablespace parameter will just ignore
+				 * tablespaces that no longer exist.
+				 *
+				 * Ask everybody to cancel their queries immediately so
+				 * we can ensure no temp files remain and we can remove the
+				 * tablespace. Nuke the entire site from orbit, it's the only
+				 * way to be sure.
+				 *
+				 * XXX: We could work out the pids of active backends
+				 * using this tablespace by examining the temp filenames in the
+				 * directory. We would then convert the pids into VirtualXIDs
+				 * before attempting to cancel them.
+				 *
+				 * We don't wait for commit because drop tablespace is
+				 * non-transactional.
+				 */
+				temp_file_users = GetConflictingVirtualXIDs(InvalidTransactionId,
+															InvalidOid,
+															false);
+				ResolveRecoveryConflictWithVirtualXIDs(temp_file_users,
+														"drop tablespace",
+														CONFLICT_MODE_ERROR_IF_NOT_IDLE,
+														InvalidXLogRecPtr);
 
-			/*
-			 * If we did recovery processing then hopefully the
-			 * backends who wrote temp files should have cleaned up and
-			 * exited by now. So lets recheck before we throw an error.
-			 * If !process_conflicts then this will just fail again.
-			 */
-			if (!remove_tablespace_directories(xlrec->ts_id, true))
+				/*
+				 * If we did recovery processing then hopefully the
+				 * backends who wrote temp files should have cleaned up and
+				 * exited by now. So lets recheck before we throw an error.
+				 * If !process_conflicts then this will just fail again.
+				 */
+				if (!remove_tablespace_directories(xlrec->ts_id, true))
+					ereport(ERROR,
+						(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+						 errmsg("tablespace %u is not empty",
+										xlrec->ts_id)));
+			}
+			else
 				ereport(ERROR,
 					(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
 					 errmsg("tablespace %u is not empty",
diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c
index a8cce99..a23c7a0 100644
--- a/src/backend/utils/cache/inval.c
+++ b/src/backend/utils/cache/inval.c
@@ -1820,13 +1820,15 @@ relation_redo(XLogRecPtr lsn, XLogRecord *record)
 	{
 		xl_rel_inval *xlrec = (xl_rel_inval *) XLogRecGetData(record);
 
-		relation_redo_inval(xlrec);
+		if (InHotStandby)
+			relation_redo_inval(xlrec);
 	}
 	else if (info == XLOG_RELATION_LOCK)
 	{
 		xl_rel_lock *xlrec = (xl_rel_lock *) XLogRecGetData(record);
 
-		relation_redo_locks(xlrec, 1);
+		if (InHotStandby)
+			relation_redo_locks(xlrec, 1);
 	}
 	else
 		elog(PANIC, "relation_redo: unknown op code %u", info);
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to