Re: Enable data checksums by default

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Greg Sabino Mullane <htamfids(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: Enable data checksums by default
Date: 2024-08-22 06:11:06
Message-ID: cec8f7c4-1c3c-47f3-b72f-4f674403bc47@eisentraut.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 15.08.24 08:38, Peter Eisentraut wrote:
> On 08.08.24 19:42, Robert Haas wrote:
>>> I'm thinking pg_upgrade could have a mode where it adds the
>>> checksum during the upgrade as it copies the files (essentially a subset
>>> of pg_checksums).  I think that would be useful for that middle tier of
>>> users who just want a good default experience.
>> That would be very nice.
>
> Here is a demo patch for that.  It turned out to be quite simple.
>
> I wrote above about a separate mode for that (like
> --copy-and-make-adjustments), but it was just as easy to stick it into
> the existing --copy mode.
>
> It would be useful to check what the performance overhead of this is
> versus a copy that does not have to make adjustments.  I expect it's
> very little.
>
> A drawback is that as written this does not work on Windows, because
> Windows uses a different code path in copyFile().  I don't know the
> reasons for that.  But it would need to be figured out.

Here is an updated patch for this. I simplified the logic a bit and
also handle the case where the read() reads less than a round number of
blocks. I did some performance testing. The overhead of computing the
checksums versus a straight --copy without checksum adjustments appears
to be around 5% wall clock time, which seems ok to me. I also looked
around the documentation to see if there is anything to update, but
didn't find anything.

I think if we can work out what to do on Windows, this could be a useful
little feature for facilitating $subject.

Attachment Content-Type Size
v1-0001-pg_upgrade-Support-for-upgrading-to-checksums-ena.patch text/plain 4.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Yugo Nagata 2024-08-22 06:15:31 Re: Disallow USING clause when altering type of generated column
Previous Message jian he 2024-08-22 05:19:00 Re: Emitting JSON to file using COPY TO