Skip to content

Commit bb4a396

Browse files
committed
hash: Support WAL consistency checking.
Kuntal Ghosh, reviewed by Amit Kapila and Ashutosh Sharma, with a few tweaks by me. Discussion: http://postgr.es/m/CAGz5QCJLERUn_zoO0eDv6_Y_d0o4tNTMPeR7ivTLBg4rUrJdwg@mail.gmail.com
1 parent 2609e91 commit bb4a396

File tree

4 files changed

+41
-4
lines changed

4 files changed

+41
-4
lines changed

doc/src/sgml/config.sgml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8267,9 +8267,9 @@ LOG: CleanUpLock: deleting: lock(0xb7acd844) id(24688,24696,0,0,0,1)
82678267
records, or to a comma-separated list of resource managers to check
82688268
only records originating from those resource managers. Currently,
82698269
the supported resource managers are <literal>heap</>,
8270-
<literal>heap2</>, <literal>btree</>, <literal>gin</>,
8271-
<literal>gist</>, <literal>sequence</>, <literal>spgist</>,
8272-
<literal>brin</>, and <literal>generic</>. Only
8270+
<literal>heap2</>, <literal>btree</>, <literal>hash</>,
8271+
<literal>gin</>, <literal>gist</>, <literal>sequence</>,
8272+
<literal>spgist</>, <literal>brin</>, and <literal>generic</>. Only
82738273
superusers can change this setting.
82748274
</para>
82758275
</listitem>

src/backend/access/hash/hash_xlog.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515
#include "postgres.h"
1616

17+
#include "access/bufmask.h"
1718
#include "access/hash.h"
1819
#include "access/hash_xlog.h"
1920
#include "access/xlogutils.h"
@@ -961,3 +962,38 @@ hash_redo(XLogReaderState *record)
961962
elog(PANIC, "hash_redo: unknown op code %u", info);
962963
}
963964
}
965+
966+
/*
967+
* Mask a hash page before performing consistency checks on it.
968+
*/
969+
void
970+
hash_mask(char *pagedata, BlockNumber blkno)
971+
{
972+
Page page = (Page) pagedata;
973+
HashPageOpaque opaque;
974+
975+
mask_page_lsn(page);
976+
977+
mask_page_hint_bits(page);
978+
mask_unused_space(page);
979+
980+
opaque = (HashPageOpaque) PageGetSpecialPointer(page);
981+
982+
if (opaque->hasho_flag & LH_UNUSED_PAGE)
983+
{
984+
/*
985+
* Mask everything on a UNUSED page.
986+
*/
987+
mask_page_content(page);
988+
}
989+
else if ((opaque->hasho_flag & LH_BUCKET_PAGE) ||
990+
(opaque->hasho_flag & LH_OVERFLOW_PAGE))
991+
{
992+
/*
993+
* In hash bucket and overflow pages, it is possible to modify the
994+
* LP_FLAGS without emitting any WAL record. Hence, mask the line
995+
* pointer flags. See hashgettuple() for details.
996+
*/
997+
mask_lp_flags(page);
998+
}
999+
}

src/include/access/hash_xlog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,5 +253,6 @@ typedef struct xl_hash_init_bitmap_page
253253
extern void hash_redo(XLogReaderState *record);
254254
extern void hash_desc(StringInfo buf, XLogReaderState *record);
255255
extern const char *hash_identify(uint8 info);
256+
extern void hash_mask(char *pagedata, BlockNumber blkno);
256257

257258
#endif /* HASH_XLOG_H */

src/include/access/rmgrlist.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ PG_RMGR(RM_STANDBY_ID, "Standby", standby_redo, standby_desc, standby_identify,
3737
PG_RMGR(RM_HEAP2_ID, "Heap2", heap2_redo, heap2_desc, heap2_identify, NULL, NULL, heap_mask)
3838
PG_RMGR(RM_HEAP_ID, "Heap", heap_redo, heap_desc, heap_identify, NULL, NULL, heap_mask)
3939
PG_RMGR(RM_BTREE_ID, "Btree", btree_redo, btree_desc, btree_identify, NULL, NULL, btree_mask)
40-
PG_RMGR(RM_HASH_ID, "Hash", hash_redo, hash_desc, hash_identify, NULL, NULL, NULL)
40+
PG_RMGR(RM_HASH_ID, "Hash", hash_redo, hash_desc, hash_identify, NULL, NULL, hash_mask)
4141
PG_RMGR(RM_GIN_ID, "Gin", gin_redo, gin_desc, gin_identify, gin_xlog_startup, gin_xlog_cleanup, gin_mask)
4242
PG_RMGR(RM_GIST_ID, "Gist", gist_redo, gist_desc, gist_identify, gist_xlog_startup, gist_xlog_cleanup, gist_mask)
4343
PG_RMGR(RM_SEQ_ID, "Sequence", seq_redo, seq_desc, seq_identify, NULL, NULL, seq_mask)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy