Streaming replication and wal skipping
Hi,
Since I had tweaked wal-skipping logic for SR before,
there were two additional changes about that;
http://archives.postgresql.org/pgsql-committers/2009-11/msg00018.php
http://archives.postgresql.org/pgsql-committers/2009-12/msg00167.php
The attached patch deals with those changes.
Also I found that XLogStandbyInfoActive() should use
XLogIsNeeded() instead of XLogArchivingMode. The patch
also does that.
Regards,
--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center
Attachments:
fix_wal_skipping_bug_0118.patchtext/x-patch; charset=US-ASCII; name=fix_wal_skipping_bug_0118.patchDownload
*** a/src/backend/commands/tablecmds.c
--- b/src/backend/commands/tablecmds.c
***************
*** 2997,3003 **** ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap)
* Prepare a BulkInsertState and options for heap_insert. Because
* we're building a new heap, we can skip WAL-logging and fsync it
* to disk at the end instead (unless WAL-logging is required for
! * archiving). The FSM is empty too, so don't bother using it.
*/
if (newrel)
{
--- 2997,3004 ----
* Prepare a BulkInsertState and options for heap_insert. Because
* we're building a new heap, we can skip WAL-logging and fsync it
* to disk at the end instead (unless WAL-logging is required for
! * archiving or streaming replication). The FSM is empty too,
! * so don't bother using it.
*/
if (newrel)
{
***************
*** 3005,3011 **** ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap)
bistate = GetBulkInsertState();
hi_options = HEAP_INSERT_SKIP_FSM;
! if (!XLogArchivingActive())
hi_options |= HEAP_INSERT_SKIP_WAL;
}
else
--- 3006,3012 ----
bistate = GetBulkInsertState();
hi_options = HEAP_INSERT_SKIP_FSM;
! if (!XLogIsNeeded())
hi_options |= HEAP_INSERT_SKIP_WAL;
}
else
*** a/src/backend/commands/vacuumlazy.c
--- b/src/backend/commands/vacuumlazy.c
***************
*** 288,294 **** vacuum_log_cleanup_info(Relation rel, LVRelStats *vacrelstats)
* No need to log changes for temp tables, they do not contain
* data visible on the standby server.
*/
! if (rel->rd_istemp || !XLogArchivingActive())
return;
(void) log_heap_cleanup_info(rel->rd_node, vacrelstats->latestRemovedXid);
--- 288,294 ----
* No need to log changes for temp tables, they do not contain
* data visible on the standby server.
*/
! if (rel->rd_istemp || !XLogIsNeeded())
return;
(void) log_heap_cleanup_info(rel->rd_node, vacrelstats->latestRemovedXid);
*** a/src/include/access/xlog.h
--- b/src/include/access/xlog.h
***************
*** 186,192 **** extern int MaxStandbyDelay;
#define XLogArchivingActive() (XLogArchiveMode)
#define XLogArchiveCommandSet() (XLogArchiveCommand[0] != '\0')
- #define XLogStandbyInfoActive() (XLogRequestRecoveryConnections && XLogArchiveMode)
/*
* This is in walsender.c, but declared here so that we don't need to include
--- 186,191 ----
***************
*** 200,205 **** extern int MaxWalSenders;
--- 199,206 ----
*/
#define XLogIsNeeded() (XLogArchivingActive() || (MaxWalSenders > 0))
+ #define XLogStandbyInfoActive() (XLogRequestRecoveryConnections && XLogIsNeeded())
+
#ifdef WAL_DEBUG
extern bool XLOG_DEBUG;
#endif
Fujii Masao wrote:
Since I had tweaked wal-skipping logic for SR before,
there were two additional changes about that;
http://archives.postgresql.org/pgsql-committers/2009-11/msg00018.php
http://archives.postgresql.org/pgsql-committers/2009-12/msg00167.phpThe attached patch deals with those changes.
Also I found that XLogStandbyInfoActive() should use
XLogIsNeeded() instead of XLogArchivingMode. The patch
also does that.
Thanks, committed.
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com