Re: Block-level CRC checks

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Gregory Stark <stark(at)enterprisedb(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Greg Stark <greg(dot)stark(at)enterprisedb(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Block-level CRC checks
Date: 2008-11-12 20:16:09
Message-ID: 20081112201609.GA7661@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Nov 12, 2008 at 11:08:13AM -0300, Alvaro Herrera wrote:
> For this to work, we would have to create two (or more) versions of the
> calculate checksum macro, one for heap pages and other for other pages.
> I'm not sure how bad is that. The bit that's worse is that we'd need to
> have external knowledge of what kind of page we're talking about (i.e.
> FlushBuffer would need to know whether a page is heap or another kind).

I think all you need is a macro (say COMP_CRC32_ONE) that adds a single
byte to the checksum, then use COMP_CRC32 for the bulk of the work.
Yes, you'd need to distinguish different kinds of pages.

Seems to me the xlog code already has plenty of examples on how to do
acrobatics with CRCs.

> However, your idea suggests something else that we could do to improve
> the patch: skip the ItemId->lp_flags during the CRC calculation. This
> would mean we wouldn't need to WAL-log those. The problem with that is
> that lp_flags are only 2 bits, so we would need to iterate zeroing them
> and restore them after CRC_COMP() instead of simply skipping.

Not sure why you're so intent on actually changing memory just so you can use
COMP_CRC32, which is just a for loop around the COMP_CRC32_ONE I
mentioned. Actually changing the memory probably means locking so why
bother.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2008-11-12 20:24:41 Re: Block-level CRC checks
Previous Message Alvaro Herrera 2008-11-12 19:50:07 Re: Block-level CRC checks