pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
"postmaster became multithreaded" is reachable
4+ messages / 2 participants
[nested] [flat]

Commits from this thread:
  2025-01-23 4f15759bdc 6c9a83f216 7ab181a29b 4d6e169c43 63a4b9f767 63644c15d7  Don't ask for bug reports about pthread_is_threaded_np() != 0.
* "postmaster became multithreaded" is reachable
@ 2025-01-23 18:22  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 4+ messages in thread

From: Tom Lane @ 2025-01-23 18:22 UTC (permalink / raw)
  To: pgsql-hackers@lists.postgresql.org; +Cc: Noah Misch <noah@leadboat.com>

ExitPostmaster() says:

    /*
     * There is no known cause for a postmaster to become multithreaded after
     * startup.  Recheck to account for the possibility of unknown causes.
     * This message uses LOG level, because an unclean shutdown at this point
     * would usually not look much different from a clean shutdown.
     */
    if (pthread_is_threaded_np() != 0)
        ereport(LOG,
                (errcode(ERRCODE_INTERNAL_ERROR),
                 errmsg_internal("postmaster became multithreaded"),
                 errdetail("Please report this to <%s>.", PACKAGE_BUGREPORT)));

We now have a report[1] of a way to trigger this error message.
It seems to boil down to "cause an error before PostmasterMain
has reached its test of pthread_is_threaded_np()", for example

$ # build with --enable-nls, using MacPorts' gettext package
$ unset LANG
$ postgres -D /foo
postgres: could not access directory "/foo": No such file or directory
Run initdb or pg_basebackup to initialize a PostgreSQL data directory.
2025-01-23 18:16:03.843 GMT [41524] LOG:  postmaster became multithreaded
2025-01-23 18:16:03.843 GMT [41524] DETAIL:  Please report this to <pgsql-bugs@lists.postgresql.org>.

I suggest therefore that we remove the "Please report a bug"
bit and instead use the much more helpful hint appearing in
PostmasterMain:

                 errhint("Set the LC_ALL environment variable to a valid locale.")));

An alternative idea (that maybe should also be done in PostmasterMain)
is to report the HINT only #ifdef __darwin__ and on other platforms
use the "Please report a bug" text.

			regards, tom lane

[1] https://www.postgresql.org/message-id/18783-d1873b95a59b9103%40postgresql.org





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

* Re: "postmaster became multithreaded" is reachable
@ 2025-01-23 18:38  Noah Misch <noah@leadboat.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 4+ messages in thread

From: Noah Misch @ 2025-01-23 18:38 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-hackers@lists.postgresql.org

On Thu, Jan 23, 2025 at 01:22:13PM -0500, Tom Lane wrote:
> ExitPostmaster() says:
> 
>     /*
>      * There is no known cause for a postmaster to become multithreaded after
>      * startup.  Recheck to account for the possibility of unknown causes.
>      * This message uses LOG level, because an unclean shutdown at this point
>      * would usually not look much different from a clean shutdown.
>      */
>     if (pthread_is_threaded_np() != 0)
>         ereport(LOG,
>                 (errcode(ERRCODE_INTERNAL_ERROR),
>                  errmsg_internal("postmaster became multithreaded"),
>                  errdetail("Please report this to <%s>.", PACKAGE_BUGREPORT)));
> 
> We now have a report[1] of a way to trigger this error message.
> It seems to boil down to "cause an error before PostmasterMain
> has reached its test of pthread_is_threaded_np()", for example
> 
> $ # build with --enable-nls, using MacPorts' gettext package
> $ unset LANG
> $ postgres -D /foo
> postgres: could not access directory "/foo": No such file or directory
> Run initdb or pg_basebackup to initialize a PostgreSQL data directory.
> 2025-01-23 18:16:03.843 GMT [41524] LOG:  postmaster became multithreaded
> 2025-01-23 18:16:03.843 GMT [41524] DETAIL:  Please report this to <pgsql-bugs@lists.postgresql.org>.

That makes sense.  Thanks for confirming it.

> I suggest therefore that we remove the "Please report a bug"
> bit and instead use the much more helpful hint appearing in
> PostmasterMain:
> 
>                  errhint("Set the LC_ALL environment variable to a valid locale.")));

That suffices.  It took a lot of years for the "Please report" message to
yield a report, so I'm not much concerned about losing reports from this
change.

> An alternative idea (that maybe should also be done in PostmasterMain)
> is to report the HINT only #ifdef __darwin__ and on other platforms
> use the "Please report a bug" text.

I gather pthread_is_threaded_np() is still macOS-only, in which case the
!darwin branch would be future-proofing only.

Another alternative would be to track whether we reached the startup-time
check, emitting a message at exit only if we did reach the startup-time check.
If a postmaster passes the startup-time check and fails the exit-time check,
changing the environment won't help.  Even so, I'm content with your first
proposal.

> [1] https://www.postgresql.org/message-id/18783-d1873b95a59b9103%40postgresql.org





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

* Re: "postmaster became multithreaded" is reachable
@ 2025-01-23 18:51  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Noah Misch <noah@leadboat.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Tom Lane @ 2025-01-23 18:51 UTC (permalink / raw)
  To: Noah Misch <noah@leadboat.com>; +Cc: pgsql-hackers@lists.postgresql.org

Noah Misch <noah@leadboat.com> writes:
> On Thu, Jan 23, 2025 at 01:22:13PM -0500, Tom Lane wrote:
>> An alternative idea (that maybe should also be done in PostmasterMain)
>> is to report the HINT only #ifdef __darwin__ and on other platforms
>> use the "Please report a bug" text.

> I gather pthread_is_threaded_np() is still macOS-only, in which case the
> !darwin branch would be future-proofing only.

Ah, I had not realized that.  Perhaps the comments about this code
should mention that?

> Another alternative would be to track whether we reached the startup-time
> check, emitting a message at exit only if we did reach the startup-time check.
> If a postmaster passes the startup-time check and fails the exit-time check,
> changing the environment won't help.  Even so, I'm content with your first
> proposal.

Yeah, seems like overcomplication.  Let's go with the simple way.

			regards, tom lane





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

* Re: "postmaster became multithreaded" is reachable
@ 2025-01-23 19:56  Noah Misch <noah@leadboat.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Noah Misch @ 2025-01-23 19:56 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-hackers@lists.postgresql.org

On Thu, Jan 23, 2025 at 01:51:32PM -0500, Tom Lane wrote:
> Noah Misch <noah@leadboat.com> writes:
> > On Thu, Jan 23, 2025 at 01:22:13PM -0500, Tom Lane wrote:
> >> An alternative idea (that maybe should also be done in PostmasterMain)
> >> is to report the HINT only #ifdef __darwin__ and on other platforms
> >> use the "Please report a bug" text.
> 
> > I gather pthread_is_threaded_np() is still macOS-only, in which case the
> > !darwin branch would be future-proofing only.
> 
> Ah, I had not realized that.  Perhaps the comments about this code
> should mention that?

Sure, your committed comment works for me.

> > Another alternative would be to track whether we reached the startup-time
> > check, emitting a message at exit only if we did reach the startup-time check.
> > If a postmaster passes the startup-time check and fails the exit-time check,
> > changing the environment won't help.  Even so, I'm content with your first
> > proposal.
> 
> Yeah, seems like overcomplication.  Let's go with the simple way.

postgr.es/c/4f15759bdcddd23e874526a6b2c0ff86e0beb042 looks fine.  Thanks.





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


end of thread, other threads:[~2025-01-23 19:56 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-01-23 18:22 "postmaster became multithreaded" is reachable Tom Lane <tgl@sss.pgh.pa.us>
2025-01-23 18:38 ` Noah Misch <noah@leadboat.com>
2025-01-23 18:51   ` Tom Lane <tgl@sss.pgh.pa.us>
2025-01-23 19:56     ` Noah Misch <noah@leadboat.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