> On Mar 16, 2021, at 10:48 AM, Tom Lane <t...@sss.pgh.pa.us> wrote:
> 
> Robert Haas <robertmh...@gmail.com> writes:
>> On Tue, Mar 16, 2021 at 12:51 PM Mark Dilger
>> <mark.dil...@enterprisedb.com> wrote:
>>> It shows them all has having attalign = 'd', but for some array types the 
>>> alignment will be 'i', not 'd'.  So it's lying a bit about the contents.  
>>> But I'm now confused why this caused problems on the two hosts where 
>>> integer and double have the same alignment?  It seems like that would be 
>>> the one place where the bug would not happen, not the one place where it 
>>> does.
> 
>> Wait, so the value in the attalign column isn't the alignment we're
>> actually using? I can understand how we might generate tuples like
>> that, if we pass the actual type to construct_array(), but shouldn't
>> we then get garbage when we deform the tuple?
> 
> No.  What should be happening there is that some arrays in the column
> get larger alignment than they actually need, but that shouldn't cause
> a problem (and has not done so, AFAIK, in the decades that it's been
> like this).  As you say, deforming the tuple is going to rely on the
> table's tupdesc for alignment; it can't know what is in the data.
> 
> I'm not entirely sure what's going on, but I think coming at this
> with the mindset that "amcheck has detected some corruption" is
> just going to lead you astray.  Almost certainly, it's "amcheck
> is incorrectly claiming corruption".  That might be from mis-decoding
> a TOAST-referencing datum.  (Too bad the message doesn't report the
> TOAST OID it probed for, so we can see if that's sane or not.)

I've added that and now get the toast pointer's va_valueid in the message:

mark.dilger@laptop280-ma-us amcheck % pg_amcheck -t "pg_catalog.pg_statistic" 
postgres
heap table "postgres"."pg_catalog"."pg_statistic", block 4, offset 2, attribute 
29:
    toasted value id 13227 for attribute 29 missing from toast table
heap table "postgres"."pg_catalog"."pg_statistic", block 4, offset 5, attribute 
27:
    toasted value id 13228 for attribute 27 missing from toast table

diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index 5ccae46375..a0be71bb7f 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -1111,8 +1111,8 @@ check_tuple_attribute(HeapCheckContext *ctx)
        }
        if (!found_toasttup)
                report_corruption(ctx,
-                                                 psprintf("toasted value for 
attribute %u missing from toast table",
-                                                                  
ctx->attnum));
+                                                 psprintf("toasted value id %u 
for attribute %u missing from toast table",
+                                                                  
toast_pointer.va_valueid, ctx->attnum));
        else if (ctx->chunkno != (ctx->endchunk + 1))
                report_corruption(ctx,
                                                  psprintf("final toast chunk 
number %u differs from expected value %u",

—
Mark Dilger
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company





Reply via email to