Extra XLOG in Checkpoint for StandbySnapshot

Lists: pgsql-hackers
From: Amit Kapila <amit(dot)kapila(at)huawei(dot)com>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: Extra XLOG in Checkpoint for StandbySnapshot
Date: 2013-01-07 12:39:19
Message-ID: 001801cdecd4$03f37080$0bda5180$@kapila@huawei.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Observation is that whenever a checkpoint happens and the wal_level
configured is hot_standby then one standby snapshot XLOG gets written with
the information of "running transaction".

So if first time checkpoint happened at specified interval, it will create
new XLOG in LogStandbySnapshot, due to which checkpoint operation doesn't
get skipped again on next interval. This is okay if there are any running
transactions, but it seems XLOG is written even if there is no running xact.

As per the analysis below is the code snippet doing this:
running = GetRunningTransactionData();
LogCurrentRunningXacts(running);

So irrespective of value of running, snapshot is getting logged.

So We can modify to change this in function LogStandbySnapshot as below:
running = GetRunningTransactionData();
if (running->xcnt > 0)
LogCurrentRunningXacts(running);

So this check will make sure that if there is no operation happening i.e. no
new running transaction, then no need to log running transaction snapshot
and hence further checkpoint operations will be skipped.

Let me know if I am missing something?

With Regards,

Amit Kapila.