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

Commit953477c

Browse files
committed
Fixes for single-page hash index vacuum.
Clear LH_PAGE_HAS_DEAD_TUPLES during replay, similar to what gets donefor btree. Update hashdesc.c for xl_hash_vacuum_one_page.Oversights in commit6977b8b spottedby Amit Kapila. Patch by Ashutosh Sharma.Bump WAL version. The original patch to make hash indexes write-aheadlogged probably should have done this, and the single page vacuumingpatch probably should have done it again, but better late than never.Discussion:http://postgr.es/m/CAA4eK1Kd=mJ9xreovcsh0qMiAj-QqCphHVQ_Lfau1DR9oVjASQ@mail.gmail.com
1 parentbc18126 commit953477c

File tree

6 files changed

+48
-3
lines changed

6 files changed

+48
-3
lines changed

‎src/backend/access/hash/hash.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,7 @@ hashbucketcleanup(Relation rel, Bucket cur_bucket, Buffer bucket_buf,
790790
OffsetNumberdeletable[MaxOffsetNumber];
791791
intndeletable=0;
792792
boolretain_pin= false;
793+
boolclear_dead_marking= false;
793794

794795
vacuum_delay_point();
795796

@@ -877,11 +878,14 @@ hashbucketcleanup(Relation rel, Bucket cur_bucket, Buffer bucket_buf,
877878
/*
878879
* Let us mark the page as clean if vacuum removes the DEAD tuples
879880
* from an index page. We do this by clearing LH_PAGE_HAS_DEAD_TUPLES
880-
* flag. Clearing this flag is just a hint; replay won't redo this.
881+
* flag.
881882
*/
882883
if (tuples_removed&&*tuples_removed>0&&
883884
opaque->hasho_flag&LH_PAGE_HAS_DEAD_TUPLES)
885+
{
884886
opaque->hasho_flag &= ~LH_PAGE_HAS_DEAD_TUPLES;
887+
clear_dead_marking= true;
888+
}
885889

886890
MarkBufferDirty(buf);
887891

@@ -891,6 +895,7 @@ hashbucketcleanup(Relation rel, Bucket cur_bucket, Buffer bucket_buf,
891895
xl_hash_deletexlrec;
892896
XLogRecPtrrecptr;
893897

898+
xlrec.clear_dead_marking=clear_dead_marking;
894899
xlrec.is_primary_bucket_page= (buf==bucket_buf) ? true : false;
895900

896901
XLogBeginInsert();

‎src/backend/access/hash/hash_xlog.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,19 @@ hash_xlog_delete(XLogReaderState *record)
859859
PageIndexMultiDelete(page,unused,unend-unused);
860860
}
861861

862+
/*
863+
* Mark the page as not containing any LP_DEAD items only if
864+
* clear_dead_marking flag is set to true. See comments in
865+
* hashbucketcleanup() for details.
866+
*/
867+
if (xldata->clear_dead_marking)
868+
{
869+
HashPageOpaquepageopaque;
870+
871+
pageopaque= (HashPageOpaque)PageGetSpecialPointer(page);
872+
pageopaque->hasho_flag &= ~LH_PAGE_HAS_DEAD_TUPLES;
873+
}
874+
862875
PageSetLSN(page,lsn);
863876
MarkBufferDirty(deletebuf);
864877
}
@@ -1078,6 +1091,7 @@ hash_xlog_vacuum_one_page(XLogReaderState *record)
10781091
Buffermetabuf;
10791092
Pagepage;
10801093
XLogRedoActionaction;
1094+
HashPageOpaquepageopaque;
10811095

10821096
xldata= (xl_hash_vacuum_one_page*)XLogRecGetData(record);
10831097

@@ -1126,6 +1140,13 @@ hash_xlog_vacuum_one_page(XLogReaderState *record)
11261140
PageIndexMultiDelete(page,unused,unend-unused);
11271141
}
11281142

1143+
/*
1144+
* Mark the page as not containing any LP_DEAD items. See comments
1145+
* in _hash_vacuum_one_page() for details.
1146+
*/
1147+
pageopaque= (HashPageOpaque)PageGetSpecialPointer(page);
1148+
pageopaque->hasho_flag &= ~LH_PAGE_HAS_DEAD_TUPLES;
1149+
11291150
PageSetLSN(page,lsn);
11301151
MarkBufferDirty(buffer);
11311152
}

‎src/backend/access/hash/hashinsert.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,14 @@ _hash_vacuum_one_page(Relation rel, Buffer metabuf, Buffer buf,
374374

375375
PageIndexMultiDelete(page,deletable,ndeletable);
376376

377+
/*
378+
* Mark the page as not containing any LP_DEAD items. This is not
379+
* certainly true (there might be some that have recently been marked,
380+
* but weren't included in our target-item list), but it will almost
381+
* always be true and it doesn't seem worth an additional page scan
382+
* to check it. Remember that LH_PAGE_HAS_DEAD_TUPLES is only a hint
383+
* anyway.
384+
*/
377385
pageopaque= (HashPageOpaque)PageGetSpecialPointer(page);
378386
pageopaque->hasho_flag &= ~LH_PAGE_HAS_DEAD_TUPLES;
379387

‎src/backend/access/rmgrdesc/hashdesc.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,23 @@ hash_desc(StringInfo buf, XLogReaderState *record)
9696
{
9797
xl_hash_delete*xlrec= (xl_hash_delete*)rec;
9898

99-
appendStringInfo(buf,"is_primary %c",
99+
appendStringInfo(buf,"clear_dead_marking %c, is_primary %c",
100+
xlrec->clear_dead_marking ?'T' :'F',
100101
xlrec->is_primary_bucket_page ?'T' :'F');
101102
break;
102103
}
103104
caseXLOG_HASH_UPDATE_META_PAGE:
104105
{
105106
xl_hash_update_meta_page*xlrec= (xl_hash_update_meta_page*)rec;
106107

108+
appendStringInfo(buf,"ntuples %g",
109+
xlrec->ntuples);
110+
break;
111+
}
112+
caseXLOG_HASH_VACUUM_ONE_PAGE:
113+
{
114+
xl_hash_vacuum_one_page*xlrec= (xl_hash_vacuum_one_page*)rec;
115+
107116
appendStringInfo(buf,"ntuples %g",
108117
xlrec->ntuples);
109118
break;

‎src/include/access/hash_xlog.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ typedef struct xl_hash_squeeze_page
197197
*/
198198
typedefstructxl_hash_delete
199199
{
200+
boolclear_dead_marking;/* TRUE if this operation clears
201+
* LH_PAGE_HAS_DEAD_TUPLES flag */
200202
boolis_primary_bucket_page;/* TRUE if the operation is for
201203
* primary bucket page */
202204
}xl_hash_delete;

‎src/include/access/xlog_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
/*
3232
* Each page of XLOG file has a header like this:
3333
*/
34-
#defineXLOG_PAGE_MAGIC0xD095/* can be used as WAL version indicator */
34+
#defineXLOG_PAGE_MAGIC0xD096/* can be used as WAL version indicator */
3535

3636
typedefstructXLogPageHeaderData
3737
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp