fix fclose and switch context

This commit is contained in:
maxz
2023-06-25 17:14:36 +08:00
parent 94c23d74ca
commit f0f99b8014
2 changed files with 8 additions and 3 deletions

View File

@ -2720,8 +2720,14 @@ static void do_switchover(uint32 term)
pg_log(PG_WARNING, _("\n switchover timeout after %d seconds. please manually check the cluster status or backtrack log.\n"), wait_seconds); pg_log(PG_WARNING, _("\n switchover timeout after %d seconds. please manually check the cluster status or backtrack log.\n"), wait_seconds);
if ((sofile = fopen(switchover_timeout_file, "w")) == NULL) { if ((sofile = fopen(switchover_timeout_file, "w")) == NULL) {
pg_log( pg_log(PG_WARNING, _(" could not create switchover timeout signal file \"%s\": %s\n"),
PG_WARNING, _(" could not create switchover timeout signal file \"%s\": %s\n"), switchover_timeout_file, strerror(errno)); switchover_timeout_file, strerror(errno));
exit(1);
}
if (fclose(sofile)) {
pg_log(PG_WARNING, _(" could not write switchover timeout signal file \"%s\": %s\n"), switchover_timeout_file,
strerror(errno));
sofile = NULL;
exit(1); exit(1);
} }
sig = SIGUSR1; sig = SIGUSR1;

View File

@ -662,7 +662,6 @@ void print_all_stack()
PG_CATCH(); PG_CATCH();
{ {
/* Must reset elog.c's state */ /* Must reset elog.c's state */
(void)MemoryContextSwitchTo(g_instance.stat_cxt.GsStackContext);
ErrorData* edata = CopyErrorData(); ErrorData* edata = CopyErrorData();
FlushErrorState(); FlushErrorState();
appendStringInfo(&result, "%s", edata->message); appendStringInfo(&result, "%s", edata->message);