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 1t2Is2-002vir-5U for pgsql-hackers@arkaria.postgresql.org; Sat, 19 Oct 2024 23:28:30 +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 1t2Iry-008uhY-IT for pgsql-hackers@arkaria.postgresql.org; Sat, 19 Oct 2024 23:28:26 +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.94.2) (envelope-from ) id 1t2Irx-008uhQ-U0 for pgsql-hackers@lists.postgresql.org; Sat, 19 Oct 2024 23:28:26 +0000 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t2Irt-001yMk-NP for pgsql-hackers@lists.postgresql.org; Sat, 19 Oct 2024 23:28:24 +0000 Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-7ea68af2f62so2607668a12.3 for ; Sat, 19 Oct 2024 16:28:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1729380499; x=1729985299; 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=Qxq7rGNm9+XI0rSgiQryaEYpR6VZ2lrluMKDYWlrIMs=; b=FoYEGQdDZQuw2/tHGF2Lh+x5k87yM4riOgqkL4iqwZlpVRNmDAzkMYx0ix2AZ7iP5s GtBLwY+PhyA6fOjA221mmfrbpdFrnjIsINKO9ADeEz1yL1rDjw0jsygybppcACV6XBVT haIty7vQHj+0xyz44z5KUSBwkhexdviPSt3XM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729380499; x=1729985299; 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=Qxq7rGNm9+XI0rSgiQryaEYpR6VZ2lrluMKDYWlrIMs=; b=Fj25RnuZctMexVmID1C+PFap37ynwEjy1Ud5b86CIo3zHilUhXLTU/nSpO8Rm1Zqdz Tfhq968O2ypaJZ0vIH0jRxtrX4/ecgzT3rOfuaKh8W4lE+uxFsaCspS9nXwFJExFUpHz xoDjcKgVpeoJC2+y3qhgAhHk8t4v5CgpSIfDRuTTOSifaMx3orIR+o0wX/yVgkH9BkrH tsjtzRUFo2VX2mXxuYaE3Eq6p2ANz78hnmp77XnJfhhVNwNvcNQi39wXVanV5jJ4rsbL St3mkQlBMHN7A3zrel+sMb8fQDAJGCddFZ8ItTsEQaVi0AsavCDnl7Yu5Kvw1186b+kX BxYA== X-Forwarded-Encrypted: i=1; AJvYcCWr5l4yhX/ePf2V98XQA0cPEK560Kr/tg2DnlEOkbhIi+O/4fNkXQDQaHxgOC35Z6AsX/2lFPMYjHyLOX+/@lists.postgresql.org X-Gm-Message-State: AOJu0YwcE5epR/hZxPuA3YYO4wSPcUNCI38yJM7AuTSRRzFf63q0bfJs OjW3/p/7oUURYM9A9Gmpw3rqcemE3XWFAZEwj9EIbssq9KptPz6gYlOrSDkS0w== X-Google-Smtp-Source: AGHT+IFC8eoD4B8+vD+s+lr29H5Z7ui2nvhv6D/TmvdKEYzIXncnvtxSMcy0yMjcaMWrse/GnIWUOQ== X-Received: by 2002:a05:6a21:e91:b0:1d9:dc8:b806 with SMTP id adf61e73a8af0-1d92c5c141amr7488415637.50.1729380498787; Sat, 19 Oct 2024 16:28:18 -0700 (PDT) Received: from google.com ([2600:1702:a20:5750::48]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71ec14159dfsm256193b3a.197.2024.10.19.16.28.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Oct 2024 16:28:17 -0700 (PDT) Date: Sat, 19 Oct 2024 16:28:15 -0700 From: Noah Misch To: Tom Lane Cc: Justin Pryzby , Robert Haas , =?utf-8?B?0JDQvdC00YDQtdC5INCg0LDRh9C40YbQutC40Lk=?= , pgsql-hackers@lists.postgresql.org Subject: Re: BUG #18545: \dt breaks transaction, calling error when executed in SET SESSION AUTHORIZATION Message-ID: <20241019232815.c6.nmisch@google.com> References: <72802.1721415837@sss.pgh.pa.us> <1722241488.182053205@f169.i.mail.ru> <3593204.1722466756@sss.pgh.pa.us> <3618203.1722473994@sss.pgh.pa.us> <916377.1722809337@sss.pgh.pa.us> <1807627.1722970465@sss.pgh.pa.us> <1912093.1726716624@sss.pgh.pa.us> <2042942.1726781733@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="DkyZ4i47+24PcPiH" Content-Disposition: inline In-Reply-To: <2042942.1726781733@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 --DkyZ4i47+24PcPiH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Sep 19, 2024 at 05:35:33PM -0400, Tom Lane wrote: > So the fix seems clear to me: RestoreRelationMap needs to happen > before anything that could result in catalog lookups. I'm kind > of inclined to move up the adjacent restores of non-transactional > low-level stuff too, particularly RestoreReindexState which has > direct impact on how catalog lookups are done. Thanks for debugging that. RestorePendingSyncs() also changes what RelationInitPhysicalAddr() puts in the relcache entry, so it needs to stay with RestoreRelationMap(). I'm attaching the fix I have in mind. Since the above (commit 126ec0b), the following has been getting an AssertPendingSyncConsistency() trap: make check-tests TESTS=reindex_catalog PG_TEST_INITDB_EXTRA_OPTS='-cwal_level=minimal -cmax_wal_senders=0' In commit range [6e086fa,126ec0b^], that failed differently, reflecting the outdated relmapper. (6e086fa is mostly innocent here, though.) I looked for ways we'd regret not back-patching commit 126ec0b and this, but I didn't find a concrete problem. After InvalidateSystemCaches(), the back-branch parallel worker relcache contains the nailed relations. Each entry then has: - rd_locator possibly outdated - rd_firstRelfilelocatorSubid==0 (correct for rd_locator) - rd_isvalid==false, from RelationReloadNailed()