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 1sDtHE-00Fr5u-FI for pgsql-bugs@arkaria.postgresql.org; Sun, 02 Jun 2024 22:02:09 +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 1sDtHD-0087Pj-Ao for pgsql-bugs@arkaria.postgresql.org; Sun, 02 Jun 2024 22:02:07 +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 1sDtHD-0087Pb-1j for pgsql-bugs@lists.postgresql.org; Sun, 02 Jun 2024 22:02:07 +0000 Received: from mx0a-00134001.pphosted.com ([205.220.160.129]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sDtH8-0022HK-3w for pgsql-bugs@lists.postgresql.org; Sun, 02 Jun 2024 22:02:05 +0000 Received: from pps.filterd (m0267960.ppops.net [127.0.0.1]) by mx0a-00134001.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 452M1uBZ003080; Sun, 2 Jun 2024 22:01:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=optiver.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=mail; bh=c2qUe FYMuiXXI7OCLUZKZqObsZ0tv054CiL33lI6/J8=; b=sjOzsGYF73VJ1gY9k8Twm vAM3CGCr0D5b/PtMQTKyiS+012DHsWc6+0uwvTMlxbb3lW1z2605WFGnRwoI9xsa F2Yee038TzWyedbFHtbXSUYaVPnr0Na3034pGXziYtR04okuhxEXk5Qz40nM0MU/ QPcrDkma0lJOgZ5mT6jmYRS45n+loVKtKYGBKzBJqFnl51H/Ci4qZ7x0pCy8r9Zf 9ih+nkyfIbj9+ZWG3++yqmN/8ucxQ08WCTaL548cM0o2xQBOVtTm/pMPWqzknH7F nF3KBVZFINnAdCA21ubV38uLSFAE1jFlpSJToiNQFvHbLXzf+lo0xwUfySGXFsi8 Q== Received: from opammb1269.comp.optiver.com ([195.246.114.78]) by mx0a-00134001.pphosted.com (PPS) with ESMTPS id 3yfw3r0unj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 02 Jun 2024 22:01:56 +0000 (GMT) Received: from opammb1267.comp.optiver.com (100.68.11.12) by opammb1269.comp.optiver.com (100.68.11.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Mon, 3 Jun 2024 00:01:53 +0200 Received: from opammb1267.comp.optiver.com ([fe80::5b6f:1976:98cd:68a7]) by opammb1267.comp.optiver.com ([fe80::5b6f:1976:98cd:68a7%13]) with mapi id 15.02.1118.026; Mon, 3 Jun 2024 00:01:53 +0200 From: Floris Van Nee To: Andres Freund CC: Tom Lane , "pgsql-bugs@lists.postgresql.org" Thread-Topic: [External] Re: error "can only drop stats once" brings down database [External] Thread-Index: AQHaZC2BJX3cZ68Gf0SnR3ukCGL5orGGQZEwgALhs4CAAGv+AIAsEUZQ Date: Sun, 2 Jun 2024 22:01:53 +0000 Message-ID: <47ca6fcc687e408287871f7eaaaf3c3b@Optiver.com> References: <215498.1708454947@sss.pgh.pa.us> <8e5cb534706a4f43bd74405c8fd91437@Optiver.com> <20240505160915.6boysum4f34siqct@awork3.anarazel.de> <20240505223546.6yvjzgqifuoiii3e@awork3.anarazel.de> In-Reply-To: <20240505223546.6yvjzgqifuoiii3e@awork3.anarazel.de> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [100.68.31.122] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: RE: error "can only drop stats once" brings down database X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16 definitions=2024-06-02_15,2024-05-30_01,2024-05-17_01 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > I suspect that the "high value" oids are related to the issue. I bet you'= re > running into OID wraparound for objects at a much higher frequency than > most users. I suspect the reason this causes problems is the problem I j= ust > found and described here: I definitely suspect oid wraparound has something to do with it. However, g= iven what I found on the other thread ( https://www.postgresql.org/message-= id/flat/17947-b9554521ad963c9c%40postgresql.org ), I don't think the two h= ave the exact same root cause. The other thread seems a clear case of 'forg= ot to call gc' when it should. >=20 > The fact that we're not triggering "stats object garbage collection" for = most > drops also explains why you're much more likely to see this on a standby > than on a primary. An a primary it's going to be rare to have a single ba= ckend > live long enough to observe an oid wraparound leading to one backend > accessing stats for the same object type with the same oid after that obj= ect > previously having been dropped. But most stats accesses on a standby are > going to be by the same process, the startup process. You'd still need s= ome > other accesses to prevent the object from being dropped "immediately", bu= t > that could be due to shorter lived processes. >=20 As mentioned on other thread, I do think garbage collection gets called as = part of pgstat_execute_transactional_drops in recovery. There's still the case of the "skip gc of entry if pending" though, however= I struggle to understand how this can lead to such an error in the recover= y process after wraparound. I'd expect the gc to happen relatively frequent= ly (at least much more frequently than a wraparound) as tables get created/= dropped quite frequently. Next to that, because the recovery process is the= only one creating/dropping relations on standby, it should be impossible t= o get in a state where the recovery "local" stats cache has a non-gc'd entr= y that should be dropped? Because when dropping, at least it removes the lo= cal cache entry (even if it cannot remove the shared one). So later, when c= reating it again in pgstat_get_entry_ref, it should always hit the pgstat_r= einit_entry path? Would it make sense to at least commit your patch to enhance the error mess= age a bit? -Floris