pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Avoid amcheck inline compression false positives.
2+ messages / 1 participants
[nested] [flat]

* pgsql: Avoid amcheck inline compression false positives.
@ 2019-02-06 23:58  Peter Geoghegan <pg@bowt.ie>
  0 siblings, 0 replies; 2+ messages in thread

From: Peter Geoghegan @ 2019-02-06 23:58 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid amcheck inline compression false positives.

The previous tacit assumption that index_form_tuple() hides differences
in the TOAST state of its input datums was wrong.  Normalize input
varlena datums by decompressing compressed values, and forming a new
index tuple for fingerprinting using uncompressed inputs.  The final
normalized representation may actually be compressed once again within
index_form_tuple(), though that shouldn't matter.  When the original
tuple is found to have no datums that are compressed inline, fingerprint
the original tuple directly.

Normalization avoids false positive reports of corruption in certain
cases.  For example, the executor can apply toasting with some inline
compression to an entire heap tuple because its input has a single
external TOAST pointer.  Varlena datums for other attributes that are
not particularly good candidates for inline compression can be
compressed in the heap tuple in passing, without the representation of
the same values in index tuples ever receiving concomitant inline
compression.

Add a test case to recreate the issue in a simpler though less realistic
way: by exploiting differences in pg_attribute.attstorage between heap
and index relations.

This bug was discovered by me during testing of an upcoming set of nbtree
enhancements.  It was also independently reported by Andreas Kunert, as
bug #15597.  His test case was rather more realistic than the one I
ended up using.

Bug: #15597
Discussion: https://postgr.es/m/CAH2-WznrVd9ie+TTJ45nDT+v2nUt6YJwQrT9SebCdQKtAvfPZw@mail.gmail.com
Discussion: https://postgr.es/m/15597-294e5d3e7f01c407@postgresql.org
Backpatch: 11-, where heapallindexed verification was introduced.

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2f541666683be0608594fad79acbe5619b49734c

Modified Files
--------------
contrib/amcheck/expected/check_btree.out |  20 +++++
contrib/amcheck/sql/check_btree.sql      |  16 ++++
contrib/amcheck/verify_nbtree.c          | 149 ++++++++++++++++++++++++++-----
3 files changed, 162 insertions(+), 23 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* pgsql: Avoid amcheck inline compression false positives.
@ 2019-02-06 23:58  Peter Geoghegan <pg@bowt.ie>
  0 siblings, 0 replies; 2+ messages in thread

From: Peter Geoghegan @ 2019-02-06 23:58 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Avoid amcheck inline compression false positives.

The previous tacit assumption that index_form_tuple() hides differences
in the TOAST state of its input datums was wrong.  Normalize input
varlena datums by decompressing compressed values, and forming a new
index tuple for fingerprinting using uncompressed inputs.  The final
normalized representation may actually be compressed once again within
index_form_tuple(), though that shouldn't matter.  When the original
tuple is found to have no datums that are compressed inline, fingerprint
the original tuple directly.

Normalization avoids false positive reports of corruption in certain
cases.  For example, the executor can apply toasting with some inline
compression to an entire heap tuple because its input has a single
external TOAST pointer.  Varlena datums for other attributes that are
not particularly good candidates for inline compression can be
compressed in the heap tuple in passing, without the representation of
the same values in index tuples ever receiving concomitant inline
compression.

Add a test case to recreate the issue in a simpler though less realistic
way: by exploiting differences in pg_attribute.attstorage between heap
and index relations.

This bug was discovered by me during testing of an upcoming set of nbtree
enhancements.  It was also independently reported by Andreas Kunert, as
bug #15597.  His test case was rather more realistic than the one I
ended up using.

Bug: #15597
Discussion: https://postgr.es/m/CAH2-WznrVd9ie+TTJ45nDT+v2nUt6YJwQrT9SebCdQKtAvfPZw@mail.gmail.com
Discussion: https://postgr.es/m/15597-294e5d3e7f01c407@postgresql.org
Backpatch: 11-, where heapallindexed verification was introduced.

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/eba775345d23d2c999bbb412ae658b6dab36e3e8

Modified Files
--------------
contrib/amcheck/expected/check_btree.out |  20 +++++
contrib/amcheck/sql/check_btree.sql      |  16 ++++
contrib/amcheck/verify_nbtree.c          | 149 ++++++++++++++++++++++++++-----
3 files changed, 162 insertions(+), 23 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2019-02-06 23:58 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-02-06 23:58 pgsql: Avoid amcheck inline compression false positives. Peter Geoghegan <pg@bowt.ie>
2019-02-06 23:58 pgsql: Avoid amcheck inline compression false positives. Peter Geoghegan <pg@bowt.ie>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox