pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums
7+ messages / 6 participants
[nested] [flat]

* Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums
@ 2018-01-10 00:31 Andreas Joseph Krogh <andreas@visena.com>
  2018-01-10 01:51 ` Re: Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums Stephen Frost <sfrost@snowman.net>
  2018-01-10 01:55 ` Re: Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums Andres Freund <andres@anarazel.de>
  0 siblings, 2 replies; 7+ messages in thread

From: Andreas Joseph Krogh @ 2018-01-10 00:31 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

På onsdag 10. januar 2018 kl. 01:01:26, skrev Andres Freund <andres@anarazel.de 
<mailto:andres@anarazel.de>>:
On 2018-01-10 00:25:08 +0100, Andreas Joseph Krogh wrote:
 > På tirsdag 09. januar 2018 kl. 23:42:45, skrev Rob Sargent <
 > robjsargent@gmail.com <mailto:robjsargent@gmail.com>>:
 >  
 >
 >    On 01/09/2018 03:30 PM, Andreas Joseph Krogh wrote:
 > På tirsdag 09. januar 2018 kl. 23:06:06, skrev Andres Freund <
 > andres@anarazel.de <mailto:andres@anarazel.de>>:
 > Hi,
 >
 >  On 2018-01-09 21:47:17 +0100, Andreas Joseph Krogh wrote:
 >  > Does PG use HW-accellerated crc if CPU supports it[1]?
 >
 >  Yes we do, for WAL checksums. The page checksums are a different
 >  algorithm though, one which has the advantage of being SIMD compatible.
 >
 >  The checksum computations have some impact, but if there's bigger impact
 >  it's much more likely to be related to the fact that some hint bit
 >  writes to a page now needs to be WAL logged.
 >  
 > But SIMD-instructions are also HW-accellerated by modern CPUs IIUC?

 Sure. Still measurable, but even if weren't, it's irrelevant given my
 primary point:

 >  The checksum computations have some impact, but if there's bigger impact
 >  it's much more likely to be related to the fact that some hint bit
 >  writes to a page now needs to be WAL logged.

 which isn't mitigated by SIMD / hardware CRC / whatnot.
 
Aha, so enabling CRC causes hint-bits to be written causing extra WAL-logging, 
which woudn't be the case without CRC enabled?
Thanks for pointing that out.
 
-- Andreas Joseph Krogh
CTO / Partner - Visena AS
Mobile: +47 909 56 963
andreas@visena.com <mailto:andreas@visena.com>
www.visena.com <https://www.visena.com;
 <https://www.visena.com;


 

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums
  2018-01-10 00:31 Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums Andreas Joseph Krogh <andreas@visena.com>
@ 2018-01-10 01:51 ` Stephen Frost <sfrost@snowman.net>
  2018-01-10 19:39   ` Re: Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums Andres Freund <andres@anarazel.de>
  1 sibling, 1 reply; 7+ messages in thread

From: Stephen Frost @ 2018-01-10 01:51 UTC (permalink / raw)
  To: Andreas Joseph Krogh <andreas@visena.com>; +Cc: pgsql-general@lists.postgresql.org

Greetings,

* Andreas Joseph Krogh (andreas@visena.com) wrote:
> Aha, so enabling CRC causes hint-bits to be written causing extra WAL-logging, 
> which woudn't be the case without CRC enabled?
> Thanks for pointing that out.

Yes, having checksums enabled forces logging of hint bits.  You can
enable wal_log_hints independently too, without having checksums, to see
what kind of an impact it'll have on your environment.

A useful documentation update might be:

---
With checksums enabled, wal_log_hints <link to the GUC's documentation>
will be enabled and each page read or write will involve calculating the
checksum for the page.
---

I'd probably just replace the "Enabling checksums may incur a noticeable
performance penalty" with the above, as it should be clear that doing
more work implies an impact on performance and that avoids the whole
question of trying to characterize in a general way something that can't
be generalized (as it's workload dependent).

Thanks!

Stephen

Attachments:

  signature.asc (application/pgp-signature, 818B) download

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums
  2018-01-10 00:31 Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums Andreas Joseph Krogh <andreas@visena.com>
  2018-01-10 01:51 ` Re: Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums Stephen Frost <sfrost@snowman.net>
@ 2018-01-10 19:39   ` Andres Freund <andres@anarazel.de>
  2018-01-10 20:23     ` Re: Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums Thomas Poty <thomas.poty@gmail.com>
  2018-01-14 10:27     ` Re: Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums Peter J. Holzer <hjp-pgsql@hjp.at>
  0 siblings, 2 replies; 7+ messages in thread

From: Andres Freund @ 2018-01-10 19:39 UTC (permalink / raw)
  To: Stephen Frost <sfrost@snowman.net>; +Cc: Andreas Joseph Krogh <andreas@visena.com>; pgsql-general@lists.postgresql.org

On 2018-01-09 20:51:17 -0500, Stephen Frost wrote:
> Greetings,
> 
> * Andreas Joseph Krogh (andreas@visena.com) wrote:
> > Aha, so enabling CRC causes hint-bits to be written causing extra WAL-logging, 
> > which woudn't be the case without CRC enabled?
> > Thanks for pointing that out.
> 
> Yes, having checksums enabled forces logging of hint bits.  You can
> enable wal_log_hints independently too, without having checksums, to see
> what kind of an impact it'll have on your environment.
> 
> A useful documentation update might be:
> 
> ---
> With checksums enabled, wal_log_hints <link to the GUC's documentation>
> will be enabled and each page read or write will involve calculating the
> checksum for the page.
> ---
> 
> I'd probably just replace the "Enabling checksums may incur a noticeable
> performance penalty" with the above, as it should be clear that doing
> more work implies an impact on performance and that avoids the whole
> question of trying to characterize in a general way something that can't
> be generalized (as it's workload dependent).

-1. I think this is underplaying the cost.

Greetings,

Andres Freund




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums
  2018-01-10 00:31 Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums Andreas Joseph Krogh <andreas@visena.com>
  2018-01-10 01:51 ` Re: Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums Stephen Frost <sfrost@snowman.net>
  2018-01-10 19:39   ` Re: Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums Andres Freund <andres@anarazel.de>
@ 2018-01-10 20:23     ` Thomas Poty <thomas.poty@gmail.com>
  2018-01-10 21:36       ` Re: Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums Jeff Janes <jeff.janes@gmail.com>
  1 sibling, 1 reply; 7+ messages in thread

From: Thomas Poty @ 2018-01-10 20:23 UTC (permalink / raw)
  To: Andres Freund <andres@anarazel.de>; +Cc: Stephen Frost <sfrost@snowman.net>; Andreas Joseph Krogh <andreas@visena.com>; pgsql-general@lists.postgresql.org

Hello,
A question seems to be, according to me, important :
How a corruption, detected thanks to data-checksums, is fixed?

Thank you,
Thomas

Le 10 janv. 2018 20:39, "Andres Freund" <andres@anarazel.de> a écrit :

> On 2018-01-09 20:51:17 -0500, Stephen Frost wrote:
> > Greetings,
> >
> > * Andreas Joseph Krogh (andreas@visena.com) wrote:
> > > Aha, so enabling CRC causes hint-bits to be written causing extra
> WAL-logging,
> > > which woudn't be the case without CRC enabled?
> > > Thanks for pointing that out.
> >
> > Yes, having checksums enabled forces logging of hint bits.  You can
> > enable wal_log_hints independently too, without having checksums, to see
> > what kind of an impact it'll have on your environment.
> >
> > A useful documentation update might be:
> >
> > ---
> > With checksums enabled, wal_log_hints <link to the GUC's documentation>
> > will be enabled and each page read or write will involve calculating the
> > checksum for the page.
> > ---
> >
> > I'd probably just replace the "Enabling checksums may incur a noticeable
> > performance penalty" with the above, as it should be clear that doing
> > more work implies an impact on performance and that avoids the whole
> > question of trying to characterize in a general way something that can't
> > be generalized (as it's workload dependent).
>
> -1. I think this is underplaying the cost.
>
> Greetings,
>
> Andres Freund
>
>

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums
  2018-01-10 00:31 Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums Andreas Joseph Krogh <andreas@visena.com>
  2018-01-10 01:51 ` Re: Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums Stephen Frost <sfrost@snowman.net>
  2018-01-10 19:39   ` Re: Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums Andres Freund <andres@anarazel.de>
  2018-01-10 20:23     ` Re: Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums Thomas Poty <thomas.poty@gmail.com>
@ 2018-01-10 21:36       ` Jeff Janes <jeff.janes@gmail.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Jeff Janes @ 2018-01-10 21:36 UTC (permalink / raw)
  To: Thomas Poty <thomas.poty@gmail.com>; +Cc: Andres Freund <andres@anarazel.de>; Stephen Frost <sfrost@snowman.net>; Andreas Joseph Krogh <andreas@visena.com>; pgsql-general@lists.postgresql.org

On Wed, Jan 10, 2018 at 12:23 PM, Thomas Poty <thomas.poty@gmail.com> wrote:

> Hello,
> A question seems to be, according to me, important :
> How a corruption, detected thanks to data-checksums, is fixed?
>

Take two full cold backups of the current mess you have, including the
executables, and lock one of them away where you can't accidentally do
something to make it worse.

Replace the hardware (or fix the software bug) which lead to this, so it
doesn't eat more of your data than it already has.

If you have a wal archive, then restore from the most recent backup and
recover it forward with the WAL, hoping your hardware problem hasn't
polluted that as well.  Make sure it rolls forward as far as you think it
should.  If you think it rolled forward all the way, then you are probably
done.  I'd take a full cold backup as well as as full pg_dump(all) at this
point and lock it away for future forensics, just in case, and also to see
if any more errors are found by the pg_dump.

I'd also extract the damaged block and inspect it.  If the value says "MQs.
Johnson" but the obvious (due to context) correction to "Mrs. Johnson"
matches what the post-recovery block also says, then I'd say you are pretty
good.  If the damage was to a floating point number or a header in which
you don't have any useful context to guide you, you might want to engage a
professional at this kind of thing if the data is very important to you.

Cheers,

Jeff

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums
  2018-01-10 00:31 Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums Andreas Joseph Krogh <andreas@visena.com>
  2018-01-10 01:51 ` Re: Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums Stephen Frost <sfrost@snowman.net>
  2018-01-10 19:39   ` Re: Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums Andres Freund <andres@anarazel.de>
@ 2018-01-14 10:27     ` Peter J. Holzer <hjp-pgsql@hjp.at>
  1 sibling, 0 replies; 7+ messages in thread

From: Peter J. Holzer @ 2018-01-14 10:27 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

On 2018-01-10 11:39:21 -0800, Andres Freund wrote:
> On 2018-01-09 20:51:17 -0500, Stephen Frost wrote:
> > * Andreas Joseph Krogh (andreas@visena.com) wrote:
> > > Aha, so enabling CRC causes hint-bits to be written causing extra WAL-logging, 
> > > which woudn't be the case without CRC enabled?
> > > Thanks for pointing that out.
> > 
> > Yes, having checksums enabled forces logging of hint bits.  You can
> > enable wal_log_hints independently too, without having checksums, to see
> > what kind of an impact it'll have on your environment.
> > 
> > A useful documentation update might be:
> > 
> > ---
> > With checksums enabled, wal_log_hints <link to the GUC's documentation>
> > will be enabled and each page read or write will involve calculating the
> > checksum for the page.
> > ---
> > 
> > I'd probably just replace the "Enabling checksums may incur a noticeable
> > performance penalty" with the above, as it should be clear that doing
> > more work implies an impact on performance and that avoids the whole
> > question of trying to characterize in a general way something that can't
> > be generalized (as it's workload dependent).
> 
> -1. I think this is underplaying the cost.

I disagree. At least two people in this thread interpreted "noticable"
as "measurable but negligible" (which I personally find a bit
surprising). Computing the CRC basically means reading the whole page
from RAM which should be fast compared to a transfer to or from disk. So
it is easy to disregard this sentence as "was probably written when a
Pentium II was new and never updated". Stephen's version draws attention
to the fact that enabling CRCs may cause extra disk writes, which rings
a much louder alarm bell for me. (When are those hint-bits set? Does this
happen often when otherwise no write would have been necessary? I have
no idea so I guess I'd better measure it!)

        hp

-- 
   _  | Peter J. Holzer    | we build much bigger, better disasters now
|_|_) |                    | because we have much more sophisticated
| |   | hjp@hjp.at         | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/;

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums
  2018-01-10 00:31 Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums Andreas Joseph Krogh <andreas@visena.com>
@ 2018-01-10 01:55 ` Andres Freund <andres@anarazel.de>
  1 sibling, 0 replies; 7+ messages in thread

From: Andres Freund @ 2018-01-10 01:55 UTC (permalink / raw)
  To: Andreas Joseph Krogh <andreas@visena.com>; +Cc: pgsql-general@lists.postgresql.org

On 2018-01-10 01:31:58 +0100, Andreas Joseph Krogh wrote:
> På onsdag 10. januar 2018 kl. 01:01:26, skrev Andres Freund <andres@anarazel.de 
> <mailto:andres@anarazel.de>>:
> On 2018-01-10 00:25:08 +0100, Andreas Joseph Krogh wrote:
>  > But SIMD-instructions are also HW-accellerated by modern CPUs IIUC?
> 
>  Sure. Still measurable, but even if weren't, it's irrelevant given my
>  primary point:
> 
>  >  The checksum computations have some impact, but if there's bigger impact
>  >  it's much more likely to be related to the fact that some hint bit
>  >  writes to a page now needs to be WAL logged.
> 
>  which isn't mitigated by SIMD / hardware CRC / whatnot.
>  
> Aha, so enabling CRC causes hint-bits to be written causing extra WAL-logging, 
> which woudn't be the case without CRC enabled?
> Thanks for pointing that out.

Well, enabling checksums enables that. CRCs don't play a role for data
checksums. CRCs are a specific class of checksums, a specific one of
those is used in our WAL logging, but the data checksum algorithm isn't
in that class.

Greetings,

Andres Freund




^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2018-01-14 10:27 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-01-10 00:31 Sv: Re: Sv: Re: Sv: Re: Sv: Re: data-checksums Andreas Joseph Krogh <andreas@visena.com>
2018-01-10 01:51 ` Stephen Frost <sfrost@snowman.net>
2018-01-10 19:39   ` Andres Freund <andres@anarazel.de>
2018-01-10 20:23     ` Thomas Poty <thomas.poty@gmail.com>
2018-01-10 21:36       ` Jeff Janes <jeff.janes@gmail.com>
2018-01-14 10:27     ` Peter J. Holzer <hjp-pgsql@hjp.at>
2018-01-10 01:55 ` Andres Freund <andres@anarazel.de>

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