Re: Hash index corruption and CLOG lookup errors from checkpoint races

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: vignesh C <vignesh21(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Subject: Re: Hash index corruption and CLOG lookup errors from checkpoint races
Date: 2026-11-03 04:08:17
Message-ID: CAGRkXqS121fDgQOCpbKJogL84wZG59fMOYtc-JCCyBioBgYeBg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Vignesh,

Thanks for catching this, and for the test. It fails on v1 as you
describe.

v2 drops the flag. _hash_alloc_buckets() now extends the file before
writing the WAL record, so a checkpoint either replays the record or
syncs the new block.

^^^^ is aligned with current heap extend behavior. Another way is to
use PG_TRY and FINALLY to reset the flag. I prefer to use
same mechanism because it is easy to understand in the future.

0001 and 0002 are unchanged.

Thanks,
Shihao.

Attachment Content-Type Size
v2-0004-Add-test-for-a-checkpoint-that-starts-during-hash.patch application/x-patch 9.2 KB
v2-0002-Add-test-for-a-checkpoint-that-starts-during-CLOG.patch application/x-patch 4.9 KB
v2-0001-Advance-oldestXid-before-truncating-CLOG.patch application/x-patch 3.8 KB
v2-0003-Extend-hash-index-before-WAL-logging-new-bucket-p.patch application/x-patch 3.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Hayato Kuroda (Fujitsu) 2026-11-03 04:20:03 RE: Fix "unexpected logical decoding status change" error; from concurrent logical decoding activation
Previous Message Fujii Masao 2026-11-03 04:07:54 Re: Incremental backup accepts a prior backup that extends past a timeline switch