Re: Postmaster fails to shut down right after crash restart

From: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
To: Sergey Shinderuk <s(dot)shinderuk(at)postgrespro(dot)ru>, Michael Paquier <michael(at)paquier(dot)xyz>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Postmaster fails to shut down right after crash restart
Date: 2026-09-03 18:08:27
Message-ID: A7D898DD-88C2-4433-8F15-87BD499C8991@yandex-team.ru
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I found an older thread about the same bug[0]. Sorry I missed it before.

Justin Pryzby reported it in December 2023. Thomas Munro reproduced it
and identified the same window: FatalError is still set, the postmaster
has not yet processed PMSIGNAL_RECOVERY_STARTED, and shutdown gets stuck
waiting for the checkpointer. Thomas proposed a fix in that thread, and
Noah Misch later reproduced the problem and suggested clearing FatalError
when the replacement startup process is launched instead [1]. There is
also an old CommitFest entry for Thomas's patch [2].

The deterministic test in patch 0002 covers that report as well. Patch
0003 takes a third approach that only became directly available
recently. HandleFatalError() did not exist when Thomas posted his
patch; after it was introduced, it asserted that FatalError was not
already set. ead8f696b7cd removed that restriction. This lets 0003
retain FatalError during crash restart and handle a shutdown request in
that interval through HandleFatalError(PMQUIT_FOR_STOP, false). The
version from [2] perhaps is easier to backpatch to 15-17 if we want to
backpatch.

Best regards, Andrey Borodin.

[0] https://www.postgresql.org/message-id/flat/ZWlrdQarrZvLsgIk%40pryzbyj2023
[1] https://www.postgresql.org/message-id/20241025181701.ed.nmisch%40google.com
[2] https://commitfest.postgresql.org/patch/4884/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Álvaro Herrera 2026-09-03 18:12:10 Re: Remove stale XXX comment in logical launcher
Previous Message Paul A Jungwirth 2026-09-03 17:45:43 Re: FOR PORTION OF silently ignored on views with DO INSTEAD rules