diff options
Diffstat (limited to 'src/backend/access')
-rw-r--r-- | src/backend/access/heap/heapam.c | 8 | ||||
-rw-r--r-- | src/backend/access/nbtree/nbtsort.c | 14 | ||||
-rw-r--r-- | src/backend/access/transam/xlog.c | 46 |
3 files changed, 65 insertions, 3 deletions
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index 5cd4f005c65..ce661a8d1b3 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.282 2010/01/14 11:08:00 sriggs Exp $ + * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.283 2010/01/20 19:43:40 heikki Exp $ * * * INTERFACE ROUTINES @@ -5074,10 +5074,16 @@ heap2_desc(StringInfo buf, uint8 xl_info, char *rec) void heap_sync(Relation rel) { + char reason[NAMEDATALEN + 30]; + /* temp tables never need fsync */ if (rel->rd_istemp) return; + snprintf(reason, sizeof(reason), "heap inserts on \"%s\"", + RelationGetRelationName(rel)); + XLogReportUnloggedStatement(reason); + /* main heap */ FlushRelationBuffers(rel); /* FlushRelationBuffers will have opened rd_smgr */ diff --git a/src/backend/access/nbtree/nbtsort.c b/src/backend/access/nbtree/nbtsort.c index 68747beae5f..772215c1810 100644 --- a/src/backend/access/nbtree/nbtsort.c +++ b/src/backend/access/nbtree/nbtsort.c @@ -59,7 +59,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtsort.c,v 1.122 2010/01/15 09:19:00 heikki Exp $ + * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtsort.c,v 1.123 2010/01/20 19:43:40 heikki Exp $ * *------------------------------------------------------------------------- */ @@ -215,6 +215,18 @@ _bt_leafbuild(BTSpool *btspool, BTSpool *btspool2) */ wstate.btws_use_wal = XLogIsNeeded() && !wstate.index->rd_istemp; + /* + * Write an XLOG UNLOGGED record if WAL-logging was skipped because + * WAL archiving is not enabled. + */ + if (!wstate.btws_use_wal && !wstate.index->rd_istemp) + { + char reason[NAMEDATALEN + 20]; + snprintf(reason, sizeof(reason), "b-tree build on \"%s\"", + RelationGetRelationName(wstate.index)); + XLogReportUnloggedStatement(reason); + } + /* reserve the metapage */ wstate.btws_pages_alloced = BTREE_METAPAGE + 1; wstate.btws_pages_written = 0; diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index a0dddcad813..a7ff66a6b86 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.358 2010/01/15 09:19:00 heikki Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.359 2010/01/20 19:43:40 heikki Exp $ * *------------------------------------------------------------------------- */ @@ -7562,6 +7562,31 @@ RequestXLogSwitch(void) } /* + * Write an XLOG UNLOGGED record, indicating that some operation was + * performed on data that we fsync()'d directly to disk, skipping + * WAL-logging. + * + * Such operations screw up archive recovery, so we complain if we see + * these records during archive recovery. That shouldn't happen in a + * correctly configured server, but you can induce it by temporarily + * disabling archiving and restarting, so it's good to at least get a + * warning of silent data loss in such cases. These records serve no + * other purpose and are simply ignored during crash recovery. + */ +void +XLogReportUnloggedStatement(char *reason) +{ + XLogRecData rdata; + + rdata.buffer = InvalidBuffer; + rdata.data = reason; + rdata.len = strlen(reason) + 1; + rdata.next = NULL; + + XLogInsert(RM_XLOG_ID, XLOG_UNLOGGED, &rdata); +} + +/* * XLOG resource manager's routines * * Definitions of info values are in include/catalog/pg_control.h, though @@ -7703,6 +7728,19 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record) LWLockRelease(ControlFileLock); } } + else if (info == XLOG_UNLOGGED) + { + if (InArchiveRecovery) + { + /* + * Note: We don't print the reason string from the record, + * because that gets added as a line using xlog_desc() + */ + ereport(WARNING, + (errmsg("unlogged operation performed, data may be missing"), + errhint("This can happen if you temporarily disable archive_mode without taking a new base backup."))); + } + } } void @@ -7752,6 +7790,12 @@ xlog_desc(StringInfo buf, uint8 xl_info, char *rec) appendStringInfo(buf, "backup end: %X/%X", startpoint.xlogid, startpoint.xrecoff); } + else if (info == XLOG_UNLOGGED) + { + char *reason = rec; + + appendStringInfo(buf, "unlogged operation: %s", reason); + } else appendStringInfo(buf, "UNKNOWN"); } |