sequence.c should be in charge of ensuring that the tuple is WAL-logged,
authorHeikki Linnakangas <[email protected]>
Mon, 20 Apr 2015 13:40:57 +0000 (16:40 +0300)
committerHeikki Linnakangas <[email protected]>
Mon, 20 Apr 2015 13:40:57 +0000 (16:40 +0300)
after a checkpoint. Otherwise you might get a torn page.
sequence_save_tuple() should force the tuple to be WAL-logged after a
checkpoint, even if !do_wal.

src/backend/commands/sequence.c

index 755df07af1bdf7df07c169858718a5e096db5774..f68dd9034f2b255754a340176d1ba2816838ef9f 100644 (file)
@@ -1029,6 +1029,13 @@ sequence_save_tuple(SequenceHandle *seqh, HeapTuple newtup, bool do_wal)
 
        page = BufferGetPage(seqh->buf);
 
+       /*
+        * Force the change to be WAL-logged, if we the tuple hasn't been logged
+        * since the last checkpoint.
+        */
+       if (RelationNeedsWAL(seqh->rel) && sequence_needs_wal(seqh))
+               do_wal = true;
+
        /*
         * If something needs to be WAL logged, acquire an xid, so this
         * transaction's commit will trigger a WAL flush and wait for