pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mark Dilger <mark.dilger@enterprisedb.com>
To: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: Aleksander Alekseev <aleksander@timescale.com>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: Extending amcheck to check toast size and compression
Date: Wed, 14 Jul 2021 07:57:47 -0700
Message-ID: <29751EFD-91D8-4F2F-8416-030AD067F260@enterprisedb.com> (raw)
In-Reply-To: <8729a485-e138-2e18-0d66-74f15ac0c3cc@iki.fi>
References: <C108F673-BF11-41A0-8436-535E998F7A74@enterprisedb.com>
	<484213DD-9F6E-440F-885F-0B31C600430F@enterprisedb.com>
	<162083278007.16755.9306912342451528285.pgcf@coridan.postgresql.org>
	<8729a485-e138-2e18-0d66-74f15ac0c3cc@iki.fi>



> On Jul 14, 2021, at 3:33 AM, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
> 
>> +/* The largest valid toast va_rawsize */
>> +#define VARLENA_SIZE_LIMIT 0x3FFFFFFF
>> +
> 
> Hmm, a toasted datum cannot be larger than MaxAllocSize, because it's reconstituted in a palloc'd datum, right?

No datum size exceeds MaxAllocSize, and no datum expands when compressed (because for those that do expand under any particular compression algorithm, we opt to instead store the datum uncompressed), so no valid toast pointer should contain a va_rawsize field greater than MaxAllocSize.  Any toast pointers that have larger va_rawsize fields are therefore corrupt.

VARLENA_SIZE_LIMIT is defined here equal to MaxAllocSize:

    src/include/utils/memutils.h:#define MaxAllocSize       ((Size) 0x3fffffff) /* 1 gigabyte - 1 */

Earlier versions of the patch used MaxAllocSize rather than defining VARLENA_SIZE_LIMIT, but review comments suggested that was less clear.

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








view thread (18+ messages)  latest in thread

Message-ID: <29751EFD-91D8-4F2F-8416-030AD067F260@enterprisedb.com>
Permalink:  ../29751EFD-91D8-4F2F-8416-030AD067F260@enterprisedb.com/
Also on:    postgresql.org/message-id/29751EFD-91D8-4F2F-8416-030AD067F260@enterprisedb.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: mark.dilger@enterprisedb.com, hlinnaka@iki.fi, aleksander@timescale.com
  Subject: Re: Extending amcheck to check toast size and compression
  In-Reply-To: <29751EFD-91D8-4F2F-8416-030AD067F260@enterprisedb.com>
  References: <C108F673-BF11-41A0-8436-535E998F7A74@enterprisedb.com> <484213DD-9F6E-440F-885F-0B31C600430F@enterprisedb.com> <162083278007.16755.9306912342451528285.pgcf@coridan.postgresql.org> <8729a485-e138-2e18-0d66-74f15ac0c3cc@iki.fi> <29751EFD-91D8-4F2F-8416-030AD067F260@enterprisedb.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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