Re: PANIC: could not flush dirty data: Cannot allocate memory

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Christoph Moench-Tegeder <cmt(at)burggraben(dot)net>
Cc: klaus(dot)mailinglists(at)pernau(dot)at, pgsql-general(at)postgresql(dot)org
Subject: Re: PANIC: could not flush dirty data: Cannot allocate memory
Date: 2022-11-15 03:03:40
Message-ID: CA+hUKG+Lc8OhTSot3Eh-qfyuarJ15G7O==AfcS_Yz6dnPGwDew@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Nov 15, 2022 at 10:54 AM Christoph Moench-Tegeder
<cmt(at)burggraben(dot)net> wrote:
> ## klaus(dot)mailinglists(at)pernau(dot)at (klaus(dot)mailinglists(at)pernau(dot)at):
> > On several servers we see the error message: PANIC: could not flush
> > dirty data: Cannot allocate memory

> Of these three places, there's an sync_file_range(), an posix_fadvise()
> and an msync(), all in src/backend/storage/file/fd.c. "Cannot allocate
> memory" would be ENOMEM, which posix_fadvise() does not return (as per
> it's docs). So this would be sync_file_range(), which could run out
> of memory (as per the manual) or msync() where ENOMEM actually means
> "The indicated memory (or part of it) was not mapped". Both cases are
> somewhat WTF for this setup.

It must be sync_file_range(). The others are fallbacks that wouldn't
apply on a modern Linux.

It has been argued before that we might have been over-zealous
applying the PANIC promotion logic to sync_file_range(). It's used to
start asynchronous writeback to make the later fsync() call fast, so
it's "only a hint", but I have no idea if it could report a writeback
error from the kernel that would then be consumed and not reported to
the later fsync(), so I defaulted to assuming that it could.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kyotaro Horiguchi 2022-11-15 03:05:33 Re: How to check stream replication latest history status
Previous Message Peter Smith 2022-11-14 23:57:08 Re: Support logical replication of DDLs