* Check for recovery signal files and if found, fsync them since they
* represent server state information. We don't sweat too much about the
* possibility of fsync failure, however.
- *
- * If present, standby signal file takes precedence. If neither is present
- * then we won't enter archive recovery.
*/
if (stat(STANDBY_SIGNAL_FILE, &stat_buf) == 0)
{
}
standby_signal_file_found = true;
}
- else if (stat(RECOVERY_SIGNAL_FILE, &stat_buf) == 0)
+
+ if (stat(RECOVERY_SIGNAL_FILE, &stat_buf) == 0)
{
int fd;
recovery_signal_file_found = true;
}
+ /*
+ * If both signal files are present, standby signal file takes precedence.
+ * If neither is present then we won't enter archive recovery.
+ */
StandbyModeRequested = false;
ArchiveRecoveryRequested = false;
if (standby_signal_file_found)
recovery_end_command = 'echo recovery_end_failed > missing_dir/xyz.file'
));
+# Create recovery.signal and confirm that both signal files exist.
+# This is necessary to test how recovery behaves when both files are present,
+# i.e., standby.signal should take precedence and both files should be
+# removed at the end of recovery.
+$node_standby2->set_recovery_mode();
+my $node_standby2_data = $node_standby2->data_dir;
+ok(-f "$node_standby2_data/recovery.signal",
+ "recovery.signal is present at the beginning of recovery");
+ok(-f "$node_standby2_data/standby.signal",
+ "standby.signal is present at the beginning of recovery");
+
$node_standby2->start;
# Save the log location, to see the failure of recovery_end_command.
# Check the logs of the standby to see that the commands have failed.
my $log_contents = slurp_file($node_standby2->logfile, $log_location);
-my $node_standby2_data = $node_standby2->data_dir;
like(
$log_contents,
qr/WARNING:.*recovery_end_command/s,
"recovery_end_command failure detected in logs after promotion");
+# Check that no signal files are present after promotion.
+ok( !-f "$node_standby2_data/recovery.signal",
+ "recovery.signal was left behind after promotion");
+ok( !-f "$node_standby2_data/standby.signal",
+ "standby.signal was left behind after promotion");
+
done_testing();