pg_filedump icon indicating copy to clipboard operation
pg_filedump copied to clipboard

Data block details were lost for GIN index

Open manaldush opened this issue 10 months ago • 0 comments

Test details: Postgres commit 91f20bc2f7e4fcf5de5c65a6cb1190e0afa91c0b (HEAD, tag: REL_17_1) pg_filedump commit 7e26baf3725a9f2ed6ce9d312178c1137fcac431 (tag: REL_17_1)

t/001_basic.pl execution is successful, but if we comment https://github.com/df7cb/pg_filedump/blob/7e26baf3725a9f2ed6ce9d312178c1137fcac431/t/001_basic.pl#L33C1-L33C21(test_btree_output), test will fail with error:

t/001_basic.pl .. 1/? Failed test 'Item found' at t/001_basic.pl line 129. Looks like you failed 1 test of 16. t/001_basic.pl .. Dubious, test returned 1 (wstat 256, 0x100) Failed 1/16 subtests

If we run test for https://github.com/df7cb/pg_filedump/blob/7e26baf3725a9f2ed6ce9d312178c1137fcac431/t/001_basic.pl#L116 manually, we will get empty Data section without any item pointers details for block 1.

*******************************************************************
* PostgreSQL File/Block Formatted Dump Utility
*
* File: data/base/5/16829
* Options used: -tvx
*******************************************************************

Block    0 ********************************************************
<Header> -----
 Block Offset: 0x00000000         Offsets: Lower      80 (0x0050)
 Block: Size 8192  Version    4            Upper    8184 (0x1ff8)
 LSN:  logid      0 recoff 0x01608350      Special  8184 (0x1ff8)
 Items:   14                      Free Space: 8104
 Checksum: 0x0000  Prune XID: 0x00000000  Flags: 0x0000 ()
 Length (including item array): 80

<Special Section> -----
 GIN Index Section:
  Flags: 0x00000008 (META)  Maxoff: 0
  Blocks: RightLink (-1)


Block    1 ********************************************************
<Header> -----
 Block Offset: 0x00002000         Offsets: Lower      36 (0x0024)
 Block: Size 8192  Version    4            Upper    8104 (0x1fa8)
 LSN:  logid      0 recoff 0x01608350      Special  8184 (0x1ff8)
 Items:    3                      Free Space: 8068
 Checksum: 0x0000  Prune XID: 0x00000000  Flags: 0x0000 ()
 Length (including item array): 36

<Data> -----

<Special Section> -----
 GIN Index Section:
  Flags: 0x00000002 (LEAF)  Maxoff: 0
  Blocks: RightLink (-1)


*** End of File Encountered. Last Block Read: 1 ***

As a resume, we have 2 problems:

  1. Test runs t/001_basic.pl aren't isolated from each other
  2. We lost data section details in GIN index dump and it seems it has never worked.

So, attached pull request fix:

  1. t/001_basic.pl test runs isolation
  2. Extend asserts for GIN test in t/001_basic.pl.
  3. Fix the problem with Data section loss(it seems we have some skipped conditions), refactor GIN FormatGinBlock method, now we have clear if/else logic for all page types and appropriate processing algorithms.
  4. No need process DELETED pages.
  5. Add support of Pending list pages
  6. Info was extended for META page
  7. Fix problem with mask values with 'sed' in TAP tests.

manaldush avatar Feb 05 '25 14:02 manaldush