pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
incorrect resource manager data checksum in record
7+ messages / 4 participants
[nested] [flat]

* incorrect resource manager data checksum in record
@ 2018-06-28 17:44  Devin Christensen <quixoten@gmail.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Devin Christensen @ 2018-06-28 17:44 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

I've been seeing this issue in multiple separate hot standby replication
chains of PostgreSQL servers (5 so far). There are 4 servers in each chain
(some running Ubuntu 14.04 and others Ubuntu 16.04. and PostgreSQL >= 10.1
and <= 11). We also have a mix of ext4 and zfs file systems. Here are the
details for each chain:

First chain
===========
dc1-pg105 (pg 10.1, ub 14.04.5) (primary)
   |
   V
dc1-pg205 (pg 10.3, ub 16.04.4)
   |
   V
dc2-pg105 (pg 10.1, ub 14.04.5) <-- error first occurs here
   |
   V
dc2-pg205 (pg 10.3, ub 16.04.4) <-- and also effects this node


Second chain
===========
dc1-pg106 (pg 10.1, ub 14.04.5, ext4) (primary)
   |
   V
dc1-pg206 (pg 10.3, ub 16.04.4, zfs)
   |
   V
dc2-pg106 (pg 10.1, ub 14.04.5, ext4) <-- error first occurs here
   |
   V
dc2-pg206 (pg 10.3, ub 16.04.4, zfs) <-- and also effects this node


Third chain
===========
dc1-pg107 (pg 10.1, ub 14.04.5, ext4) (primary)
   |
   V
dc1-pg207 (pg 10.3, ub 16.04.4, zfs)
   |
   V
dc2-pg107 (pg 10.1, ub 14.04.5, ext4) <-- error first occurs here
   |
   V
dc2-pg207 (pg 10.3, ub 16.04.4, zfs) <-- and also effects this node


Fourth chain
===========
dc1-pg108 (pg 10.3, ub 16.04.4, ext4) (primary)
   |
   V
dc1-pg208 (pg 10.3, ub 16.04.4, zfs)
   |
   V
dc2-pg108 (pg 10.3, ub 16.04.4, ext4) <-- error first occurs here
   |
   V
dc2-pg208 (pg 10.3, ub 16.04.4, zfs) <-- and also effects this node


Fifth chain
===========
dc1-pg110 (pg 10.3, ub 16.04.4, ext4) (primary)
   |
   V
dc1-pg210 (pg 10.3, ub 16.04.4, zfs)
   |
   V
dc2-pg110 (pg 10.3, ub 16.04.4, ext4) <-- error first occurs here
   |
   V
dc2-pg210 (pg 10.3, ub 16.04.4, zfs) <-- and also effects this node


The pattern is the same, regardless of ubuntu or postgresql versions. I'm
concerned this is somehow a ZFS corruption bug, because the error always
occurs downstream of the first ZFS node and ZFS is a recent addition. I
don't know enough about what this error means, and haven't found much
online. When I restart the nodes effected, replication resumes normally,
with no known side-effects that I've discovered so far, but I'm no longer
confident that the data downstream from the primary is valid. Really not
sure how best to start tackling this issue, and hoping to get some
guidance. The error is infrequent. We have 11 total replication chains, and
this error has occurred on 5 of those chains in approximately 2 months.

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

* Re: incorrect resource manager data checksum in record
@ 2018-06-28 22:13  Thomas Munro <thomas.munro@enterprisedb.com>
  parent: Devin Christensen <quixoten@gmail.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Thomas Munro @ 2018-06-28 22:13 UTC (permalink / raw)
  To: Devin Christensen <quixoten@gmail.com>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>

On Fri, Jun 29, 2018 at 5:44 AM, Devin Christensen <quixoten@gmail.com>
wrote:
> The pattern is the same, regardless of ubuntu or postgresql versions. I'm
> concerned this is somehow a ZFS corruption bug, because the error always
> occurs downstream of the first ZFS node and ZFS is a recent addition. I
> don't know enough about what this error means, and haven't found much
> online. When I restart the nodes effected, replication resumes normally,
> with no known side-effects that I've discovered so far, but I'm no longer
> confident that the data downstream from the primary is valid. Really not
> sure how best to start tackling this issue, and hoping to get some
guidance.
> The error is infrequent. We have 11 total replication chains, and this
error
> has occurred on 5 of those chains in approximately 2 months.

It's possible and sometimes expected to see that error when there has been
a crash, but you didn't mention that.  From your description it sounds like
it's happening in the middle of streaming, right?  My first thought was
that the filesystem change is surely a red herring.  But... I did find this
similar complaint that involves an ext4 primary and a btrfs replica:

https://dba.stackexchange.com/questions/116569/postgresql-docker-incorrect-resource-manager-data-che...

I'm having trouble imagining how the filesystem could be triggering a
problem though (unless ZoL is dramatically less stable than on other
operating systems, "ZFS ate my bytes" seems like a super unlikely theory).
Perhaps by being slower, it triggers a bug elsewhere?  We did have a report
recently of ZFS recycling WAL files very slowly (presumably because when it
moves the old file to become the new file, it finishes up slurping it back
into memory even though we're just going to overwrite it, and it can't see
that because our writes don't line up with the ZFS record size, possibly
unlike ye olde write-in-place 4k block filesystems, but that's just my
guess).  Does your machine have ECC RAM?

-- 
Thomas Munro
http://www.enterprisedb.com

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

* Re: incorrect resource manager data checksum in record
@ 2018-06-29 01:14  Devin Christensen <quixoten@gmail.com>
  parent: Thomas Munro <thomas.munro@enterprisedb.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Devin Christensen @ 2018-06-29 01:14 UTC (permalink / raw)
  To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>

> From your description it sounds like it's happening in the middle of
streaming, right?

Correct. None of the instances in the chain experience a crash. Most of the
time I see the "incorrect resource manager data checksum in record" error,
but I've also seen it manifested as:

invalid magic number 8813 in log segment 000000030000AEC20000009C, offset
15335424

> I did find this similar complaint that involves an ext4 primary and a
btrfs replica:

It is interesting that my issue occurs on the first hop from ZFS to ext4. I
have not seen any instances of this happening going from the ext4 primary
to the first ZFS replica.

> We did have a report recently of ZFS recycling WAL files very slowly

Do you know what version of ZFS that effected? We're currently on 0.6.5.6,
but could upgrade to 0.7.5 on Ubuntu 18.04

> Does your machine have ECC RAM?

Yes, all the servers have registered ECC RAM.

---

I'm considering changing the replication configuration from:

ext4 -> zfs -> ext4 -> zfs

to

ext4 -> zfs -> zfs -> ext4

If the issue only occurs downstream of ZFS, this will give me twice as many
chances for it to occur, and I would expect to see some instances where
only the last ext4 node is effected, and some where the last ZFS and the
last ext4 node is effected. Not sure how much it helps, but at least I
might be able to collect more data until I find a reliable way to reproduce.

---

FYI, I'd be happy to discuss paid consulting if this is an issue in your
wheelhouse and that's something you're interested in.


On Thu, Jun 28, 2018 at 4:13 PM Thomas Munro <thomas.munro@enterprisedb.com>
wrote:

> On Fri, Jun 29, 2018 at 5:44 AM, Devin Christensen <quixoten@gmail.com>
> wrote:
> > The pattern is the same, regardless of ubuntu or postgresql versions. I'm
> > concerned this is somehow a ZFS corruption bug, because the error always
> > occurs downstream of the first ZFS node and ZFS is a recent addition. I
> > don't know enough about what this error means, and haven't found much
> > online. When I restart the nodes effected, replication resumes normally,
> > with no known side-effects that I've discovered so far, but I'm no longer
> > confident that the data downstream from the primary is valid. Really not
> > sure how best to start tackling this issue, and hoping to get some
> guidance.
> > The error is infrequent. We have 11 total replication chains, and this
> error
> > has occurred on 5 of those chains in approximately 2 months.
>
> It's possible and sometimes expected to see that error when there has been
> a crash, but you didn't mention that.  From your description it sounds like
> it's happening in the middle of streaming, right?  My first thought was
> that the filesystem change is surely a red herring.  But... I did find this
> similar complaint that involves an ext4 primary and a btrfs replica:
>
>
> https://dba.stackexchange.com/questions/116569/postgresql-docker-incorrect-resource-manager-data-che...
>
> I'm having trouble imagining how the filesystem could be triggering a
> problem though (unless ZoL is dramatically less stable than on other
> operating systems, "ZFS ate my bytes" seems like a super unlikely theory).
> Perhaps by being slower, it triggers a bug elsewhere?  We did have a report
> recently of ZFS recycling WAL files very slowly (presumably because when it
> moves the old file to become the new file, it finishes up slurping it back
> into memory even though we're just going to overwrite it, and it can't see
> that because our writes don't line up with the ZFS record size, possibly
> unlike ye olde write-in-place 4k block filesystems, but that's just my
> guess).  Does your machine have ECC RAM?
>
>
> --
> Thomas Munro
> http://www.enterprisedb.com
>

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

* Re: incorrect resource manager data checksum in record
@ 2018-06-29 02:02  Thomas Munro <thomas.munro@enterprisedb.com>
  parent: Devin Christensen <quixoten@gmail.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Thomas Munro @ 2018-06-29 02:02 UTC (permalink / raw)
  To: Devin Christensen <quixoten@gmail.com>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>

On Fri, Jun 29, 2018 at 1:14 PM, Devin Christensen <quixoten@gmail.com> wrote:
>> From your description it sounds like it's happening in the middle of
>> streaming, right?
>
> Correct. None of the instances in the chain experience a crash. Most of the
> time I see the "incorrect resource manager data checksum in record" error,
> but I've also seen it manifested as:
>
> invalid magic number 8813 in log segment 000000030000AEC20000009C, offset
> 15335424

I note that that isn't at a segment boundary.  Is that also the case
for the other error?

One theory would be that there is a subtle FS cache coherency problem
between writes and reads of a file from different processes
(causality), on that particular stack.  Maybe not too many programs
pass data through files with IPC to signal progress in this kinda
funky way, but that'd certainly be a violation of POSIX if it didn't
work correctly and I think people would know about that so I feel a
bit silly suggesting it.  To follow that hypothesis to the next step:
I suppose it succeeds after you restart because it requests the whole
segment again and gets a coherent copy all the way down the chain.
Another idea would be that our flush pointer tracking and IPC is
somehow subtly wrong and that's exposed by different timing leading to
incoherent reads, but I feel like we would know about that by now too.

I'm not really a replication expert, so I could be missing something
simple here.  Anyone?

>> I did find this similar complaint that involves an ext4 primary and a
>> btrfs replica:
>
> It is interesting that my issue occurs on the first hop from ZFS to ext4. I
> have not seen any instances of this happening going from the ext4 primary to
> the first ZFS replica.

I happen to have a little office server that uses ZFS so I left it
chugging through a massive pgbench session with a chain of 3 replicas
while I worked on other stuff, and didn't see any problems (no ext4
involved though, this is a FreeBSD box).  I also tried
--wal-segsize=1MB (a feature of 11) to get some more frequent
recycling happening just in case it was relevant.

>> We did have a report recently of ZFS recycling WAL files very slowly
>
> Do you know what version of ZFS that effected? We're currently on 0.6.5.6,
> but could upgrade to 0.7.5 on Ubuntu 18.04

I think that issue is fundamental/all versions, and has something to
with the record size (if you have 128KB ZFS records and someone writes
8KB, it probably needs to read a whole 128KB record in, whereas with
ext4 et al you have 4KB blocks and the OS can very often skip reading
it in because it can see you're entirely overwriting blocks), and
possibly the COW design too (I dunno).  Here's the recent thread,
which points back to an older one, from some Joyent guys who I gather
are heavy ZFS users:

https://www.postgresql.org/message-id/flat/CACPQ5FpEY9CfUF6XKs5sBBuaOoGEiO8KD4SuX06wa4ATsesaqg%40mai...

There was a ZoL bug that made headlines recently but that was in 0.7.7
so not relevant to your case.

-- 
Thomas Munro
http://www.enterprisedb.com




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

* Incorrect resource manager data checksum in record with zfs and compression
@ 2022-10-03 19:41  John Bolliger <johnbolliger@gmail.com>
  0 siblings, 1 reply; 7+ messages in thread

From: John Bolliger @ 2022-10-03 19:41 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

This is a follow up to
https://www.postgresql.org/message-id/CANQ55Tsoa6%3Dvk2YkeVUN7qO-2YdqJf_AMVQxqsVTYJm0qqQQuw%40mail.g...,
which I am at the same company as the original poster.

Our architecture is similar but all of the servers are now on ZFS now and
Postgres 13.8 with Ubuntu 18.04+ and still doing streaming replication, all
with ECC memory and 26-64 cores with 192gb ram+ on top of a ZPOOL made out
of NVMe PCIe SSDs.

A101 (primary) -> A201 (replica) -> B101(primary) -> B201 (replica).

We are seeing this error occur about once per week (across all postgres
clusters/chains). It is the same pattern we have been seeing for a number
of years now.

Possibly relevant configuration options:

wal_init_zero=on


The last time this occurred I grabbed the good WAL file from the parent,
and the corrupted WAL file from the descendant. Comparing them showed no
differences until 12Mb in where the "good" WAL file continued, and the
"bad" WAL file was zeros until the end of the file.

When the "good" WAL file is copied from the parent and to the descendant,
replication resumes and the descendant becomes a healthy replica once again.

After doing some investigation I partially suspected that
https://github.com/postgres/postgres/commit/dd9b3fced83edb51a3e2f44d3d4476a45d0f5a24
could
possibly impact this behavior and fix the issues. But we saw this occur on
13.8 between two nodes.

I am almost done on a tool that will tail the postgresql journal and walk
up the chain to the primary and get the WAL file name for the LSN in the
error message, then sync and overwrite the bad WAL file from the parent,
but I hope I can track down the actual bug here, rather than relying upon a
process to fix this after the fact.

--
John Bolliger

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

* Re: Incorrect resource manager data checksum in record with zfs and compression
@ 2022-10-04 00:54  Michael Paquier <michael@paquier.xyz>
  parent: John Bolliger <johnbolliger@gmail.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Michael Paquier @ 2022-10-04 00:54 UTC (permalink / raw)
  To: John Bolliger <johnbolliger@gmail.com>; +Cc: pgsql-general@lists.postgresql.org

On Mon, Oct 03, 2022 at 12:41:23PM -0700, John Bolliger wrote:
> Our architecture is similar but all of the servers are now on ZFS now and
> Postgres 13.8 with Ubuntu 18.04+ and still doing streaming replication, all
> with ECC memory and 26-64 cores with 192gb ram+ on top of a ZPOOL made out
> of NVMe PCIe SSDs.
> 
> A101 (primary) -> A201 (replica) -> B101(primary) -> B201 (replica).

replica -> primary does not really make sense for physical
replication.  Or do you mean that B101 is itself a standby doing
streaming from A201?
--
Michael

Attachments:

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

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

* Re: Incorrect resource manager data checksum in record with zfs and compression
@ 2022-10-04 01:01  John Bolliger <johnbolliger@gmail.com>
  parent: Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 7+ messages in thread

From: John Bolliger @ 2022-10-04 01:01 UTC (permalink / raw)
  To: Michael Paquier <michael@paquier.xyz>; +Cc: pgsql-general@lists.postgresql.org

I mistyped and yes B101 is a replica node, not primary.

The correct architecture is
A101(primary) -> A201(replica) -> B101(replica) -> B201(replica)

On Mon, Oct 3, 2022 at 5:55 PM Michael Paquier <michael@paquier.xyz> wrote:

> On Mon, Oct 03, 2022 at 12:41:23PM -0700, John Bolliger wrote:
> > Our architecture is similar but all of the servers are now on ZFS now and
> > Postgres 13.8 with Ubuntu 18.04+ and still doing streaming replication,
> all
> > with ECC memory and 26-64 cores with 192gb ram+ on top of a ZPOOL made
> out
> > of NVMe PCIe SSDs.
> >
> > A101 (primary) -> A201 (replica) -> B101(primary) -> B201 (replica).
>
> replica -> primary does not really make sense for physical
> replication.  Or do you mean that B101 is itself a standby doing
> streaming from A201?
> --
> Michael
>

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


end of thread, other threads:[~2022-10-04 01:01 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-06-28 17:44 incorrect resource manager data checksum in record Devin Christensen <quixoten@gmail.com>
2018-06-28 22:13 ` Thomas Munro <thomas.munro@enterprisedb.com>
2018-06-29 01:14   ` Devin Christensen <quixoten@gmail.com>
2018-06-29 02:02     ` Thomas Munro <thomas.munro@enterprisedb.com>
2022-10-03 19:41 Incorrect resource manager data checksum in record with zfs and compression John Bolliger <johnbolliger@gmail.com>
2022-10-04 00:54 ` Re: Incorrect resource manager data checksum in record with zfs and compression Michael Paquier <michael@paquier.xyz>
2022-10-04 01:01   ` Re: Incorrect resource manager data checksum in record with zfs and compression John Bolliger <johnbolliger@gmail.com>

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