diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index a7ae183248..cecd5eb7f8 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -2377,6 +2377,8 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible) int npages; int startidx; uint32 startoffset; + List * notify_list = NIL; + ListCell * cell; /* We should always be inside a critical section here */ Assert(CritSectionCount > 0); @@ -2547,7 +2549,7 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible) LogwrtResult.Flush = LogwrtResult.Write; /* end of page */ if (XLogArchivingActive()) - XLogArchiveNotifySeg(openLogSegNo); + notify_list = lappend_int(notify_list, openLogSegNo); XLogCtl->lastSegSwitchTime = (pg_time_t) time(NULL); XLogCtl->lastSegSwitchLSN = LogwrtResult.Flush; @@ -2619,6 +2621,13 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible) LogwrtResult.Flush = LogwrtResult.Write; } + foreach(cell, notify_list) + { + int segno = lfirst_int(cell); + XLogArchiveNotifySeg(segno); + } + list_free(notify_list); + /* * Update shared-memory status *