Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita8d539f

Browse files
committed
To support external compression of archived WAL data, add a flag bit to
WAL records that shows whether it is safe to remove full-page images(ie, whether or not an on-line backup was in progress when the WAL entrywas made). Also make provision for an XLOG_NOOP record type that can beused to fill in the extra space when decompressing the data for restore.This is the portion of Koichi Suzuki's "full page writes" patch thathas to go into the core database. The remainder of that work is twoexternal compression and decompression programs, which for the time beingwill undergo separate development on pgfoundry. Per discussion.Also, twiddle the handling of BTREE_SPLIT records to ensure it'll bepossible to compress them (the previous coding caused essential infoto be omitted). The other commonly-used record types seem OK already,with the possible exception of GIN and GIST WAL records, which I don'tunderstand well enough to opine on.
1 parent2f2717d commita8d539f

File tree

6 files changed

+53
-17
lines changed

6 files changed

+53
-17
lines changed

‎src/backend/access/nbtree/nbtinsert.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.156 2007/04/11 20:47:37 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.157 2007/05/20 21:08:19 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1034,21 +1034,23 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright,
10341034
* Log the new item and its offset, if it was inserted on the left
10351035
* page. (If it was put on the right page, we don't need to explicitly
10361036
* WAL log it because it's included with all the other items on the
1037-
* right page.) Show these as belonging to the left page buffer,
1038-
* so that they are not stored if XLogInsert decides it needs a
1039-
* full-page image of the left page.
1037+
* right page.) Show the new item as belonging to the left page buffer,
1038+
* so that it is not stored if XLogInsert decides it needs a full-page
1039+
* image of the left page. We store the offset anyway, though, to
1040+
* support archive compression of these records.
10401041
*/
10411042
if (newitemonleft)
10421043
{
10431044
lastrdata->next=lastrdata+1;
10441045
lastrdata++;
1046+
10451047
lastrdata->data= (char*)&newitemoff;
10461048
lastrdata->len=sizeof(OffsetNumber);
1047-
lastrdata->buffer=buf;/* backup block 1 */
1048-
lastrdata->buffer_std= true;
1049+
lastrdata->buffer=InvalidBuffer;
10491050

10501051
lastrdata->next=lastrdata+1;
10511052
lastrdata++;
1053+
10521054
lastrdata->data= (char*)newitem;
10531055
lastrdata->len=MAXALIGN(newitemsz);
10541056
lastrdata->buffer=buf;/* backup block 1 */
@@ -1064,6 +1066,7 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright,
10641066
*/
10651067
lastrdata->next=lastrdata+1;
10661068
lastrdata++;
1069+
10671070
lastrdata->data=NULL;
10681071
lastrdata->len=0;
10691072
lastrdata->buffer=buf;/* backup block 1 */

‎src/backend/access/nbtree/nbtxlog.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.43 2007/04/11 20:47:38 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.44 2007/05/20 21:08:19 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -292,14 +292,17 @@ btree_xlog_split(bool onleft, bool isroot,
292292
}
293293

294294
/* Extract newitem and newitemoff, if present */
295-
if (onleft&& !(record->xl_info&XLR_BKP_BLOCK_1))
295+
if (onleft)
296296
{
297-
IndexTupleDataitupdata;
298-
299297
/* Extract the offset (still assuming 16-bit alignment) */
300298
memcpy(&newitemoff,datapos,sizeof(OffsetNumber));
301299
datapos+=sizeof(OffsetNumber);
302300
datalen-=sizeof(OffsetNumber);
301+
}
302+
303+
if (onleft&& !(record->xl_info&XLR_BKP_BLOCK_1))
304+
{
305+
IndexTupleDataitupdata;
303306

304307
/*
305308
* We need to copy the tuple header to apply IndexTupleDSize, because

‎src/backend/access/transam/xlog.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.268 2007/04/30 21:01:52 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.269 2007/05/20 21:08:19 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -783,6 +783,19 @@ begin:;
783783
}
784784
}
785785

786+
/*
787+
* If we backed up any full blocks and online backup is not in progress,
788+
* mark the backup blocks as removable. This allows the WAL archiver to
789+
* know whether it is safe to compress archived WAL data by transforming
790+
* full-block records into the non-full-block format.
791+
*
792+
* Note: we could just set the flag whenever !forcePageWrites, but
793+
* defining it like this leaves the info bit free for some potential
794+
* other use in records without any backup blocks.
795+
*/
796+
if ((info&XLR_BKP_BLOCK_MASK)&& !Insert->forcePageWrites)
797+
info |=XLR_BKP_REMOVABLE;
798+
786799
/*
787800
* If there isn't enough space on the current XLOG page for a record
788801
* header, advance to the next page (leaving the unused space as zeroes).
@@ -5868,6 +5881,10 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
58685881

58695882
RecoveryRestartPoint(&checkPoint);
58705883
}
5884+
elseif (info==XLOG_NOOP)
5885+
{
5886+
/* nothing to do here */
5887+
}
58715888
elseif (info==XLOG_SWITCH)
58725889
{
58735890
/* nothing to do here */
@@ -5894,6 +5911,10 @@ xlog_desc(StringInfo buf, uint8 xl_info, char *rec)
58945911
checkpoint->nextMultiOffset,
58955912
(info==XLOG_CHECKPOINT_SHUTDOWN) ?"shutdown" :"online");
58965913
}
5914+
elseif (info==XLOG_NOOP)
5915+
{
5916+
appendStringInfo(buf,"xlog no-op");
5917+
}
58975918
elseif (info==XLOG_NEXTOID)
58985919
{
58995920
OidnextOid;

‎src/include/access/xlog.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/access/xlog.h,v 1.76 2007/01/05 22:19:51 momjian Exp $
9+
* $PostgreSQL: pgsql/src/include/access/xlog.h,v 1.77 2007/05/20 21:08:19 tgl Exp $
1010
*/
1111
#ifndefXLOG_H
1212
#defineXLOG_H
@@ -66,8 +66,7 @@ typedef struct XLogRecord
6666
/*
6767
* If we backed up any disk blocks with the XLOG record, we use flag bits in
6868
* xl_info to signal it. We support backup of up to 3 disk blocks per XLOG
69-
* record.(Could support 4 if we cared to dedicate all the xl_info bits for
70-
* this purpose; currently bit 0 of xl_info is unused and available.)
69+
* record.
7170
*/
7271
#defineXLR_BKP_BLOCK_MASK0x0E/* all info bits used for bkp blocks */
7372
#defineXLR_MAX_BKP_BLOCKS3
@@ -76,6 +75,15 @@ typedef struct XLogRecord
7675
#defineXLR_BKP_BLOCK_2XLR_SET_BKP_BLOCK(1)/* 0x04 */
7776
#defineXLR_BKP_BLOCK_3XLR_SET_BKP_BLOCK(2)/* 0x02 */
7877

78+
/*
79+
* Bit 0 of xl_info is set if the backed-up blocks could safely be removed
80+
* from a compressed version of XLOG (that is, they are backed up only to
81+
* prevent partial-page-write problems, and not to ensure consistency of PITR
82+
* recovery). The compression algorithm would need to extract data from the
83+
* blocks to create an equivalent non-full-page XLOG record.
84+
*/
85+
#defineXLR_BKP_REMOVABLE0x01
86+
7987
/*
8088
* Sometimes we log records which are out of transaction control.
8189
* Rmgr may "or" XLOG_NO_TRAN into info passed to XLogInsert to indicate this.

‎src/include/access/xlog_internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
1212
* Portions Copyright (c) 1994, Regents of the University of California
1313
*
14-
* $PostgreSQL: pgsql/src/include/access/xlog_internal.h,v 1.20 2007/04/30 21:01:53 tgl Exp $
14+
* $PostgreSQL: pgsql/src/include/access/xlog_internal.h,v 1.21 2007/05/20 21:08:19 tgl Exp $
1515
*/
1616
#ifndefXLOG_INTERNAL_H
1717
#defineXLOG_INTERNAL_H
@@ -71,7 +71,7 @@ typedef struct XLogContRecord
7171
/*
7272
* Each page of XLOG file has a header like this:
7373
*/
74-
#defineXLOG_PAGE_MAGIC0xD061/* can be used as WAL version indicator */
74+
#defineXLOG_PAGE_MAGIC0xD062/* can be used as WAL version indicator */
7575

7676
typedefstructXLogPageHeaderData
7777
{

‎src/include/catalog/pg_control.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $PostgreSQL: pgsql/src/include/catalog/pg_control.h,v 1.37 2007/04/03 04:14:26 tgl Exp $
11+
* $PostgreSQL: pgsql/src/include/catalog/pg_control.h,v 1.38 2007/05/20 21:08:19 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -44,6 +44,7 @@ typedef struct CheckPoint
4444
/* XLOG info values for XLOG rmgr */
4545
#defineXLOG_CHECKPOINT_SHUTDOWN0x00
4646
#defineXLOG_CHECKPOINT_ONLINE0x10
47+
#defineXLOG_NOOP0x20
4748
#defineXLOG_NEXTOID0x30
4849
#defineXLOG_SWITCH0x40
4950

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp