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.96) (envelope-from ) id 1w6FIo-0046Kp-0p for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Mar 2026 22:05:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w6FIm-00CPnp-2a for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Mar 2026 22:05:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w6FIm-00CPng-1d for pgsql-hackers@lists.postgresql.org; Fri, 27 Mar 2026 22:05:12 +0000 Received: from mail-ot1-x330.google.com ([2607:f8b0:4864:20::330]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w6FIk-00000001YZU-1egD for pgsql-hackers@postgresql.org; Fri, 27 Mar 2026 22:05:12 +0000 Received: by mail-ot1-x330.google.com with SMTP id 46e09a7af769-7d74aa6bcdbso1500335a34.2 for ; Fri, 27 Mar 2026 15:05:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774649108; x=1775253908; darn=postgresql.org; h=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=G3UXZlIuRaVB/nVXo/DV7XDtlkDc/DYqanoI5ICcBxE=; b=qT+vyvtaiV+WhaB5Kns55TdTAoc6TxLQDNjtW1THOpgmQpUrFdDFqh/uXUIRPmYexd tgQRwf3bYlXd7Sw9wMZ7TD3e77sJz5CeTjwgnxBWBbGZLmrw2iCpI+eR/2lYb85hWuUK 4ao35LKOn8M292XZlaiCd5hlIlV3vWmOq2d0o8BV40oEhmwmHLw3sKEk+DCXB1WyFlXR QsOm5WqcYRpCrCrMVu1owBExtW2KPcXTNHn7hgttuuTHEYzkVhRkOYMt2coV18SBg2St yTAF8ooIUrL9T0cUckUjJnzO24BOcl77aybc8D9/58DT6DfPM0/WtVSAbswVd7K/NrUU d2WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774649108; x=1775253908; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G3UXZlIuRaVB/nVXo/DV7XDtlkDc/DYqanoI5ICcBxE=; b=GXXh2huWeJNNnkZ7OHEBE+YcwYAAOsvWB2hGq50EFdcPCvy/w+vpFC0Fn/HAqtw8ok I+Lz5iYtcev7CeSBEu03eq2hpgrWfokslFurTYcMzXxt+Sdrj3mmbrtONQkUx+mh0Pb1 Nmj79FGUPwpQRDWskZKI5NYeohjkY4gO6nFRDyA8wccBbq3b/Q58WXaV/wZezD31NhDu Y9MQD+25F1uffXrRwXl6PgxYdlf12b8XGWZaRGZBFjuV6urkku2+Xv4jn7aJr5XiePBP JSz5p/SlbZAwRTVsg0nFu6F/LmFq4MN7C5gU4Zenp/2UYjJQL7qyqrNBa3ZjKgbLzGn1 f55A== X-Forwarded-Encrypted: i=1; AJvYcCW0qixrekk/iAJSQ1BQh6DZQRXl+wiD1klV1m0fxlffC3QCpmdOmdelkmF3DDjd15qV9culGsbhEwHUM0Oo@postgresql.org X-Gm-Message-State: AOJu0YwlIkS86kJKWztKunmfBvamDXmDsNhHAS0efNk3CqcvlYt+mxV1 e7f7GaNF5+GyGKYJXvw3blGCGRoF3eEqZpuWRyhOXTyj5LloXC4fQqWx X-Gm-Gg: ATEYQzzngRaWAES2UIkiFlajYF25lnrssb9QUp5SWs6p4JkjjdTsFjgF4AQjS/2KOrQ P80xcJD3Nl/bSThgnqXosj9AVrAOSxgvVCDP+BVRIl1Utx+x3EIGigqvqEmYcRzT6bakbVpRSim RD4PYuS0iT4yFuEbSwDEh/mpjoOM7KO0oXzdYTm+mXJMqTUIhE7aaKtkR6PGu2/WSFYZYJZdB4I vnUS4/r6H6RKTpFHoFu3vW39ax7HxL1r5qu0AnFUMsR1QdotRY6vD2dm/GiY4P+V9H4qzi0ywPJ wKq6lShttOLwR+GYAcwn9QbivadCSw1vpSbj0PXBMunyHF989HsAk2tXaD6HgwFqFF609//u2WX I/URPNF+jOhN+n+AdtZ08xZpDfOa0xcGPhzDK7gbmGDARpuh6jtHPK6TCsutMaW7RnVaiWKctlO 6gO/8CkTpzUK9Y1yzzKgn+uN07PcMRWAyMEa+r8WSGTSay7n+azgxu/Zp0j0y8sEvxlsMDck7X2 I7ODqZ69ER1HBjduLLtvQ== X-Received: by 2002:a05:6830:6a11:b0:7d7:d702:401c with SMTP id 46e09a7af769-7d9faf5af44mr2492408a34.32.1774649108430; Fri, 27 Mar 2026 15:05:08 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7da0a864514sm344856a34.26.2026.03.27.15.05.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Mar 2026 15:05:07 -0700 (PDT) Date: Fri, 27 Mar 2026 17:05:06 -0500 From: Nathan Bossart To: Andres Freund Cc: Heikki Linnakangas , Sami Imseih , Robert Haas , "pgsql-hackers@postgresql.org" Subject: Re: Clean up NamedLWLockTranche stuff Message-ID: References: <0ba6cb8c-a893-4445-b8fa-fa9f52be8f39@iki.fi> <1e1dd445-730e-40c9-b0f7-4d153bb013fb@iki.fi> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Lz5NZmdVPmVGc+6p" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Lz5NZmdVPmVGc+6p Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Mar 27, 2026 at 04:50:12PM -0500, Nathan Bossart wrote: > On Fri, Mar 27, 2026 at 05:22:33PM -0400, Andres Freund wrote: >> TRAP: failed Assert("MemoryContextIsValid(context)"), File: "mcxt.c", Line: 1270, PID: 230491 >> [...](ExceptionalCondition+0x54)[0xaaaae186c204] >> [...](MemoryContextAllocExtended+0x0)[0xaaaae18a2a24] >> [...](RequestNamedLWLockTranche+0x6c)[0xaaaae16e7310] >> [...](process_shmem_requests+0x28)[0xaaaae1881628] >> [...](PostgresSingleUserMain+0xc4)[0xaaaae1701a34] >> [...](main+0x6ac)[0xaaaae12a2adc] >> /lib/aarch64-linux-gnu/libc.so.6(__libc_start_main+0xe8)[0xffff99713dd8] >> [...](+0xf2b98)[0xaaaae12a2b98] >> Aborted >> pg_rewind: error: postgres single-user mode in target cluster failed > > Hm. AFAICT PostmasterContext isn't created in single-user mode, and the > commit in question has RequestNamedLWLockTranche() allocate requests there. > I guess the idea is to allow backends to free that memory after forking > from postmaster, but we don't do that for the NamedLWLockTrancheRequests > list. Maybe we should surround the last part of that function with > MemoryContextSwitchTo(...) to either TopMemoryContext or PostmasterContext > depending on whether we're in single-user mode. Concretely, like the attached. -- nathan --Lz5NZmdVPmVGc+6p Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=0001-fix-RequestNamedLWLockTranche.patch