From: Heikki Linnakangas Date: Mon, 31 May 2010 10:44:37 +0000 (+0000) Subject: Send all outstanding WAL before exiting when smart shutdown is requested. X-Git-Tag: REL9_0_BETA2~32 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e0b581acd2def7d3e237f73e953d1fd4d1ed428f;p=postgresql Send all outstanding WAL before exiting when smart shutdown is requested. This was broken by my previous patch to send WAL in smaller batches. Patch by Fujii Masao. --- diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index 0d38054008..1d3b9aa861 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -30,7 +30,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/replication/walsender.c,v 1.22 2010/05/26 22:34:49 heikki Exp $ + * $PostgreSQL: pgsql/src/backend/replication/walsender.c,v 1.23 2010/05/31 10:44:37 heikki Exp $ * *------------------------------------------------------------------------- */ @@ -394,8 +394,10 @@ WalSndLoop(void) */ if (ready_to_stop) { - XLogSend(&output_message, &caughtup); - shutdown_requested = true; + if (!XLogSend(&output_message, &caughtup)) + goto eof; + if (caughtup) + shutdown_requested = true; } /* Normal exit from the walsender is here */ @@ -458,7 +460,6 @@ eof: static void InitWalSnd(void) { - /* use volatile pointer to prevent code rearrangement */ int i; /* @@ -474,6 +475,7 @@ InitWalSnd(void) */ for (i = 0; i < max_wal_senders; i++) { + /* use volatile pointer to prevent code rearrangement */ volatile WalSnd *walsnd = &WalSndCtl->walsnds[i]; SpinLockAcquire(&walsnd->mutex);