Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tb29T-007P8d-Dg for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Jan 2025 18:42:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tb29Q-002K6S-VK for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Jan 2025 18:42:00 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tb26E-002Ekr-RH for pgsql-hackers@lists.postgresql.org; Thu, 23 Jan 2025 18:38:43 +0000 Received: from mail-oi1-x22a.google.com ([2607:f8b0:4864:20::22a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tb26C-0018Vr-18 for pgsql-hackers@lists.postgresql.org; Thu, 23 Jan 2025 18:38:41 +0000 Received: by mail-oi1-x22a.google.com with SMTP id 5614622812f47-3eb7ecc3c54so679581b6e.0 for ; Thu, 23 Jan 2025 10:38:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1737657520; x=1738262320; darn=lists.postgresql.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=2PzPK9DcGGX22+PWaPQxyJOi1Wh8NThOpgpA1cewK00=; b=Hadk92Ra9VksJLBf42AjjLFAByPAg/WXP/dmyZPvN+2e5tgw0KhQ89jt//WlSJB305 JgCOiJ1ytrNFyNWbAEs7u+MCi2RqN/c/8IWKULJ4tn8h/OvWVHu0W9uibgiYYOAgroak lK533xcxPRamMTA+AyswDrG9nmCqM2CrpPkvs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737657520; x=1738262320; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2PzPK9DcGGX22+PWaPQxyJOi1Wh8NThOpgpA1cewK00=; b=GG4MGDHco/H1wg8uyx6miDgXOVLf0pHNl2n+uHlhXQrQyTLGZDUw0G+FNG7+GZdZ97 JzNp8746CHYj6HR5HfwWM9AwpiI6bgVy9DEWQF8D8FJDZ9+hYvlo09mO9q+aVdmG1nEO G37rFakaOIxoFOuTE429t2U9DwFrT2fP3dNa3hmrT6khYM+psmFKPnS8Xi0ib2E1BZaa vBzhFRra2VdM/ssE0vGJBmY6xnpNuS3RthQWVEPhNiApXvFTMoEifR6ox/c8N5cfWdhB YvHEicZV2e3/XdbSTJWsvLeNLX5MnOoXYv0HFD/uxhZvUgGqhcaPVdMZRiBJtUYjAHaY ZNMw== X-Gm-Message-State: AOJu0YwIjaoVQj2g7lKODLX4kTMU6uhdbirYZBk2rnh0EZleWn5QodlJ JPCbLZ6aUxVQQKAwvs9coBaCly/MhGwnQXucoGDU02JdpLVjr0YAA82vm6UsFQ== X-Gm-Gg: ASbGnctaSEUhGEMGUu/cNg7nf1AOeuzT81uZZ9eFGS8QYfdcZ1ro2vxHYZD4jintK3H /wUA0GgYjwNezFVogfHr/KaNe+haWSdRSAAHONsrTlpxGxsOqzrb5ve/65cpaxtnWJsGgbemC+8 fhV/FYm4scmj7JFLIupGh5DEJtkOmxmZEDZY3tgQ0H93Q+L4u61I82VBfqAcuaRAC7PD/UfdmnT SqrNuBQKxc14usw5+I5Ci+7o4ORTVegxVYJb7HBYc/ScUTQa0uJ4W03d552WsMHrLod+4HEfcQ= X-Google-Smtp-Source: AGHT+IG0XwQRWa9/NQ6l3c7/MGqQapPHeK+wpnFuKcFamDv8/Goyu+Sv/qqg+8ghFvRMD2PfvtiBCw== X-Received: by 2002:a05:6808:1b90:b0:3eb:6044:5a89 with SMTP id 5614622812f47-3f19fca11f2mr18244782b6e.19.1737657520109; Thu, 23 Jan 2025 10:38:40 -0800 (PST) Received: from google.com ([2600:1702:a20:5750::46]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3f1f09810ebsm6061b6e.39.2025.01.23.10.38.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Jan 2025 10:38:39 -0800 (PST) Date: Thu, 23 Jan 2025 10:38:37 -0800 From: Noah Misch To: Tom Lane Cc: pgsql-hackers@lists.postgresql.org Subject: Re: "postmaster became multithreaded" is reachable Message-ID: <20250123183837.79.nmisch@google.com> References: <206317.1737656533@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <206317.1737656533@sss.pgh.pa.us> User-Agent: Mutt/2.2.12 (2023-09-09) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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 . 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