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 1w6F4M-00465g-2U for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Mar 2026 21:50:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w6F4L-00CJif-0B for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Mar 2026 21:50:17 +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.96) (envelope-from ) id 1w6F4K-00CJiW-2H for pgsql-hackers@lists.postgresql.org; Fri, 27 Mar 2026 21:50:17 +0000 Received: from mail-oi1-x22d.google.com ([2607:f8b0:4864:20::22d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w6F4J-00000001Obx-1t5C for pgsql-hackers@postgresql.org; Fri, 27 Mar 2026 21:50:16 +0000 Received: by mail-oi1-x22d.google.com with SMTP id 5614622812f47-463f00cda04so1464568b6e.2 for ; Fri, 27 Mar 2026 14:50:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774648215; x=1775253015; 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=Sv2AVL4TrRsY+6nbW/l012UzRcQXYoKMoyUhCfqEeaw=; b=KQxCz75GZdTwI0wA6I+MC5BQF5SZUfGX8bUzPqCHHuvPYKHKADztvx/NU/gOigvAGc MvGeWnhb/uxnD4XAm7F6rF9jXik3i0QtR5NRoNIu8ayVC5CZHqXoSmnW5/VHMUUnAnQ/ 8pV7lEVU9wLOZ3XFeE566mXfJX7Llw3mICMwgBH2FhSl/Cey2IE0aBmfnx/OeSwK+Fx7 TKEy/B+mWTl+KUwkbBh/GiUyeDYhB6Ap22G686Rirmi6JMSD2HwmNHA53DZiCOaLvs00 p4DHh6HDiifaZnKLzGLFna4Ud3nriVdewKFOu1E6GR8zBQLxLSCJslNwgqXu55OyzjF8 P0Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774648215; x=1775253015; 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=Sv2AVL4TrRsY+6nbW/l012UzRcQXYoKMoyUhCfqEeaw=; b=rLSC5DQjmXa6kPDwJD+ASfnoHrOUo8wpFbmEkrQYSsHHZvXofvyfTvkNeK6/i3G84S +vnE+WhWQymaNVld2N56aF5rnKwo8WXokICU8HpbM/ApHk74Y5lBmv1bSgg6Xb9tzQtQ nItJlXyP3/+7AyrnCIaL1fVOi0tYsKSnDlpAaF2UAOLXX5F1AkfXYYnu71INaELx/6YI XXSKxsFROkjh+JoZ0uAHS0MwFGX0t6qti7Srnp1ntBXL17LCAUWpM0kHBDTgi35Y/3ce DxqqkftvjtY+jGZPd+uAgO2harVWRPFTxFk/vyqNxSCAWMTe3vucsDUc1i7TDUuPqH0N UjQw== X-Forwarded-Encrypted: i=1; AJvYcCW6x531b3K9+2tsYDfAZe7ne/9fizY0bYSjbK1IiOK5gCq+wqO1w4Q42nCduKFaJPPPg1sFhnhFVuDo8X8h@postgresql.org X-Gm-Message-State: AOJu0YwGdOeYhTBz6NcEu5KWLsGIdLzIQK1njB5zOmdVIX/35jdCrLKF E0SzMwpvMJN6GuZ9nuSRj05qTeCvLJXhXgPRgTq+8w6OGQdPenBcNFGo X-Gm-Gg: ATEYQzyiXvo2LW5nILVENRUgxu3dvIcnNrT4l1tw3SzluBIZgbggSRxRSKVkHlwri+D o+ZQgavC2aeLYRTkCPTk9ab/ce/ZsuO0bbwYNh1lU3oBlNt9PlYEQNwJClOCwZTIxdCgI7u3Q62 tkAHdBRXV8CVec3F3c5yQ37gV1E/A6piUmTo1HR5vfVarwhMGGoE8ohM//I1D0R4WMRgjfLRGcg 0tEA3D1OPVh60DCrgBCliKhie/ZtdNM8I0ijisxvvXo+HRVCFpfof3/6WDdBIfDxSBrhd9jgv2X xyF4v5K0nmevU0zJQPArNd/6nNwEEA34z+MgnB3PVBmOo3uL/UK+tDMnGQC0S3vGdGg6hLJy9kH hrSOUuZ8cpvKtg/aC69752tFZZG36/uNH5SJwR56PKAuP9NM7Cw1wtgOVTOk0voSRltqUDBhqHf dVNFStn2YXPl1yS0D0ngvStWDpaxc+Ojv3M/ezrnTdsf8AQlyEYt+098nOSvBnK6iYWKDGqpzDg 7n/05bzas4JkebuLOzY/w== X-Received: by 2002:a05:6808:17aa:b0:45f:434:9c1c with SMTP id 5614622812f47-46a8a3bbed8mr2051839b6e.12.1774648214723; Fri, 27 Mar 2026 14:50:14 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 5614622812f47-46aa03e4acesm129029b6e.17.2026.03.27.14.50.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Mar 2026 14:50:14 -0700 (PDT) Date: Fri, 27 Mar 2026 16:50:12 -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: <47aaf57e-1b7b-4e12-bda2-0316081ff50e@iki.fi> <0ba6cb8c-a893-4445-b8fa-fa9f52be8f39@iki.fi> <1e1dd445-730e-40c9-b0f7-4d153bb013fb@iki.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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. -- nathan