Re: smgrzeroextend clarification

From: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: smgrzeroextend clarification
Date: 2023-05-19 15:03:21
Message-ID: ec5a1562-97ca-239d-b492-00bb563d43ec@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I have committed some of the unrelated formatting changes separately, so
what's left now is attached.

On 17.05.23 01:38, Andres Freund wrote:
>> - I left this for smgrzeroextend():
>>
>> FIXME: why both blocknum and nblocks
>
> I guess you're suggesting that we would do an lstat() to figure out the size
> instead? Or use some cached size? That'd not be trivial to add - and it just
> seems unrelated to smgzerorextend(), it's just as true for smgrextend().

What smgzerorextend() does now seems sensible to me. I'd just like one
or two sentences that document its API. Right now, blocknum and nblocks
are not documented at all. Of course, we can guess, but I'm also
interested in edge cases. What are you supposed to pass for blocknum?
What happens if it's not right after the current last block? You
answered that, but is that just what happens to happen, or do we
actually want to support that? What happens if blocknum is *before* the
currently last block? Would that overwrite the last existing blocks
with zero? What if nblocks is negative? Does that zero out blocks
backwards?

Obviously, the answer for most of these right now is that you're not
supposed to do that. But as the smgrextend() + hash index case shows,
these things tend to grow in unexpected directions.

Also, slightly unrelated to the API, did we consider COW file systems?
Like, is explicitly allocating blocks of zeroes sensible on btrfs?

Attachment Content-Type Size
v2-0001-WIP-Improve-smgr-source-code-comments.patch text/plain 5.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2023-05-19 15:04:16 Re: WAL Insertion Lock Improvements
Previous Message Tom Lane 2023-05-19 14:59:47 Re: Conflict between regression tests namespace & transactions due to recent changes