Hi,

When I created the trigger file to activate the standby server,
I got the segmentation fault:

  sby [11342]: LOG:  trigger file found: ../trigger
  sby [11343]: FATAL:  terminating walreceiver process due to
administrator command
  sby [11342]: LOG:  redo done at 0/10000E0
  sby [11342]: LOG:  last completed transaction was at log time
2000-01-01 09:21:04.685861+09
  sby [11341]: LOG:  startup process (PID 11342) was terminated by
signal 11: Segmentation fault
  sby [11341]: LOG:  terminating any other active server processes

This happens in the following scenario:

0. The trigger file is found.
1. The variable StandbyMode is reset to FALSE before re-fetching
   the last applied record.
2. That record attempts to be read from the archive.
3. RestoreArchivedFile() goes through the following condition
   expression because the StandbyMode is off.

     if (StandbyMode && recoveryRestoreCommand == NULL)
         goto not_available;

4. RestoreArchivedFile() wrongly constructs the command to be
   executed even though restore_command has not been supplied
   (this is possible in standby mode).
   ---> Segmentation fault!

The attached patch would fix the bug.

Regards,

-- 
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center
*** a/src/backend/access/transam/xlog.c
--- b/src/backend/access/transam/xlog.c
***************
*** 2759,2766 **** RestoreArchivedFile(char *path, const char *xlogfname,
  	uint32		restartLog;
  	uint32		restartSeg;
  
! 	/* In standby mode, restore_command might not be supplied */
! 	if (StandbyMode && recoveryRestoreCommand == NULL)
  		goto not_available;
  
  	/*
--- 2759,2769 ----
  	uint32		restartLog;
  	uint32		restartSeg;
  
! 	/*
! 	 * Returns FALSE if restore_command has not been supplied. This is
! 	 * possible in standby mode.
! 	 */
! 	if (recoveryRestoreCommand == NULL)
  		goto not_available;
  
  	/*
-- 
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