pgsql: Check for relation length overrun soon enough.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Check for relation length overrun soon enough.
Date: 2021-09-09 15:46:15
Message-ID: E1mOMFj-0001F6-Ha@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Check for relation length overrun soon enough.

We don't allow relations to exceed 2^32-1 blocks, because block
numbers are 32 bits and the last possible block number is reserved
to mean InvalidBlockNumber. There is a check for this in mdextend,
but that's really way too late, because the smgr API requires us to
create a buffer for the block-to-be-added, and we do not want to
have any buffer with blocknum InvalidBlockNumber. (Such a case
can trigger assertions in bufmgr.c, plus I think it might confuse
ReadBuffer's logic for data-past-EOF later on.) So put the check
into ReadBuffer.

Per report from Christoph Berg. It's been like this forever,
so back-patch to all supported branches.

Discussion: https://postgr.es/m/YTn1iTkUYBZfcODk@msg.credativ.de

Branch
------
REL9_6_STABLE

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

Modified Files
--------------
src/backend/storage/buffer/bufmgr.c | 9 +++++++++
src/backend/storage/smgr/md.c | 3 ++-
2 files changed, 11 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2021-09-09 16:29:10 pgsql: pgbench: Stop counting skipped transactions as soon as timer is
Previous Message Fujii Masao 2021-09-09 15:02:17 pgsql: Fix issue with WAL archiving in standby.