Re: Tepid: selective index updates for heap relations - Mailing list pgsql-hackers

From Greg Burd
Subject Re: Tepid: selective index updates for heap relations
Date
Msg-id a35235bb-a3b4-45cc-8e4a-7e57556a9250@app.fastmail.com
Whole thread
List pgsql-hackers
Hello,

I've rebased Tepid (e994f956e48) and done a bit of minor cleanup.  No new features, no design changes. Same nine
commits,same structure. Two commits are unchanged (the HOT-behavior test commit and the benchmark harness). 

* pg_surgery now understands SIU stubs. heap_force_freeze/heap_force_kill skip xid-free HOT-indexed stubs instead of
erroringor corrupting them, with a regression test that builds a real stub. (This was the one substantive gap the macOS
reviewerflagged against v48.) 

* Prune/vacuum correctness — the most important fixes:
 - Restored upstream's hard elog(ERROR, "dead heap-only tuple … not linked to from any HOT chain") guard for the
classic-HOTcase. v48 silently reclaimed such a tuple, which would have masked real heap corruption; SIU's legitimate
stubhandling is now cleanly separated from that error path. 
 - Fixed a primary/standby divergence bug: the lazy_vacuum_heap_page WAL record must always log a hardcoded false
cleanup-lockflag (that call site never re-points redirects/stubs), and v48 was passing the runtime-variable value. 
 - Added bounds checking (Assert(bmnatts <= relnatts) plus a defensive clamp) before the stub-bitmap union/subset
operations,closing a stack-buffer-overflow risk from a corrupt or unbounded stub natts. 

* Executor / index-scan:
 - Fixed an out-of-bounds read in ExecCompareSlotAttrs (missing continue after the system-attribute branch).
 - RelationGetIndexedAttrs now parses raw catalog text directly rather than going through
RelationGetIndexExpressions/Predicate,which could const-fold away Var references and under-report indexed attributes. 
 - Removed dead code (an unused idx_attrs fetch in simple_heap_update, an empty branch in index_delete_check_htid) and
correctedan inaccurate "must mirror heap_multi_insert" comment. 

* amcheck now reports corruption on out-of-range or self-referential stub forward links, matching the existing
redirect-linkcheck. 

* Statistics: the n_hot_indexed counter and the matched/skipped pgstat counters now exclude stubs and fire only after
thepartial-index predicate check (v48 over-counted). 

* Logical replication: rebased over upstream's new conflict_log_destination feature (a subscription bit-flag collision
resolved,0x00080000->0x00100000), and the subscription field/option renamed hotindexedmode→hotindexedonapply for
clarity,with a matching psql \dRs+ display fix (shows the word, not the raw char code). 

* Tests: hardened the count-sensitive tables against an autovacuum lock-steal race (autovacuum_enabled = false), and
replaceda relpages-based assertion (only updated by VACUUM/ANALYZE, so trivially true) with a real pg_relation_size
check.

* Plus routine cleanups — removed a few redundant/unused includes, fixed typos.

best.

-greg
Attachment

pgsql-hackers by date:

Previous
From: Rui Zhao
Date:
Subject: Re: [PATCH] Preserve replication origin OIDs in pg_upgrade
Next
From: Heikki Linnakangas
Date:
Subject: Re: pg_rewind: Skip vanished source files during traversal