On Wed, Nov 25, 2015 at 7:18 PM, Magnus Hagander <mag...@hagander.net>
wrote:

>
> On Wed, Nov 25, 2015 at 10:19 AM, Magnus Hagander <mag...@hagander.net>
> wrote:
>
>> Are the values for the log locations really relevant for backup
>> connections? And if they are, we need to document it :) ISTM we are just
>> more or less leaking random data out there?
>>
>> I'm talking about the actual state=backup connection - not the connection
>> if we're using -x with pg_basebackup. Where we have output like:
>>
>> state            | backup
>> sent_location    | 0/0
>> write_location   | 2/76CE0000
>> flush_location   | 2/76CC0000
>> replay_location  | 2/76CBF938
>>
>> I'm thinking those fields should probably all be NULL for state=backup?
>>
>
Hm. You would basically get that when a backup WAL sender is reusing the
sender of another node that is not here anymore.


> In particular, it seems that in InitWalSenderSlot, we only initialize the
> sent location. Perhaps this is needed?
>

Yes, that would be nice to start with a clean state. At the same time, I am
noticing that pg_stat_get_wal_senders() is comparing flush, apply and write
directly with 0. I think those should be InvalidXLogRecPtr. Combined with
your patch it gives the attached.
-- 
Michael
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 4a4643e..c135672 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -1962,6 +1962,9 @@ InitWalSenderSlot(void)
 			 */
 			walsnd->pid = MyProcPid;
 			walsnd->sentPtr = InvalidXLogRecPtr;
+			walsnd->write = InvalidXLogRecPtr;
+			walsnd->flush = InvalidXLogRecPtr;
+			walsnd->apply = InvalidXLogRecPtr;
 			walsnd->state = WALSNDSTATE_STARTUP;
 			walsnd->latch = &MyProc->procLatch;
 			SpinLockRelease(&walsnd->mutex);
@@ -2821,15 +2824,15 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
 			values[1] = CStringGetTextDatum(WalSndGetStateString(state));
 			values[2] = LSNGetDatum(sentPtr);
 
-			if (write == 0)
+			if (XLogRecPtrIsInvalid(write))
 				nulls[3] = true;
 			values[3] = LSNGetDatum(write);
 
-			if (flush == 0)
+			if (XLogRecPtrIsInvalid(flush))
 				nulls[4] = true;
 			values[4] = LSNGetDatum(flush);
 
-			if (apply == 0)
+			if (XLogRecPtrIsInvalid(apply))
 				nulls[5] = true;
 			values[5] = LSNGetDatum(apply);
 
-- 
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