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 1sGgi7-00FxuK-Jg for pgsql-bugs@arkaria.postgresql.org; Mon, 10 Jun 2024 15:13:28 +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 1sGgi5-00DOse-Oh for pgsql-bugs@arkaria.postgresql.org; Mon, 10 Jun 2024 15:13: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 1sGgi5-00DOs8-ET for pgsql-bugs@lists.postgresql.org; Mon, 10 Jun 2024 15:13:26 +0000 Received: from mx0b-00134001.pphosted.com ([205.220.172.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 1sGgi3-000x6F-2o for pgsql-bugs@lists.postgresql.org; Mon, 10 Jun 2024 15:13:25 +0000 Received: from pps.filterd (m0267962.ppops.net [127.0.0.1]) by mx0a-00134001.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45A3oZ8Q005477; Mon, 10 Jun 2024 15:13:18 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=fIYRR dj05bXL4hy9gGdd2zcuyB4YM/mjN/6uaDW4gcE=; b=OtWeIKB+OcZEVW2P8p1xR kF8Jo1WwQoxi2LQTa8We3+YuKHlr1/NiHPsU3NS7qYmC8X3p35VBVo6lIkUh+S/J nNBRNrXj+5jFspBGYWm1QWGL1dQYs+T6hfublleHCaRpkC/3J7OF2gJayRnsaj0V r1OnGmnc83ANcfBZoXpJsQX8ujV7nI541U6IeDUIemLuMZzAWCjRxpAnBm3azS1t czP7MncRxjr+LgQFMZR++r6lELWSHo64uKIBj3VvXzzX9KKaUcifuvc+fFVgucqa xz+tAwN+suqdZUcBSUteVrKxqXqYbYD+KGGIGPkl7OIvQFgpnkCk4lchqgFcF0TU A== Received: from opammb1269.comp.optiver.com ([195.246.114.78]) by mx0a-00134001.pphosted.com (PPS) with ESMTPS id 3ymd5n1sdk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 10 Jun 2024 15:13:18 +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, 10 Jun 2024 17:13:16 +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, 10 Jun 2024 17:13:16 +0200 From: Floris Van Nee To: Michael Paquier , Andres Freund CC: Bertrand Drouvot , Kyotaro Horiguchi , "tgl@sss.pgh.pa.us" , "pgsql-bugs@lists.postgresql.org" Thread-Topic: [External] Re: error "can only drop stats once" brings down database [External] Thread-Index: AQHaZC2BJX3cZ68Gf0SnR3ukCGL5orGGQZEwgALhs4CAAGv+AIAsEUZQgAHuzgCAAg6I8IABEKoAgAAWkICAAUFxAIAAGUIAgAAHhACAAGn2gIAABMQAgAHQRtCAArEdAIAAq52w Date: Mon, 10 Jun 2024 15:13:16 +0000 Message-ID: References: <68430b1b76d44558b7b07ae8c69151f6@Optiver.com> <20240607.101540.1972690976596948719.horikyota.ntt@gmail.com> <20240607031258.l4fcpvulo3uee5g6@awork3.anarazel.de> <2cb577e176774caca28c724898768a38@Optiver.com> In-Reply-To: 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.680,FMLib:17.12.28.16 definitions=2024-06-10_02,2024-06-10_01,2024-05-17_01 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk >=20 > Nah, ignoring the double-drop error does not seem right to me. > Wouldn't it make the most sense to ensure that the stats are dropped on t= he > standby instead on the first DROP replayed even if there are still refere= nces > to it hold, making sure that the stats entry with this OID is gone before > reusing it after wraparound? Agree it doesn't seem right to just ignore. However I don't believe we can = just drop the stats entry on replay of the first drop, right? That's why all thi= s logic with pgstat_request_entry_refs_gc was invented in the first place, to get backends to clean up their refs first. If we free it, backends can't see th= e 'dropped' attribute anymore. This can only be changed if the whole gc mechanism gets revamped to use a different mechanism to notify backends that their local reference in pgStatEntryRefHash is suddenly invalid. I dou= bt that's backpatchable.=20 On primary this doesn't happen because it's guaranteed that 'drop stats' ca= n only ever happen after a 'create stats' call. This is the thing that's diff= erent on a replica: it is possible to get 'drop stats' twice, without a 'create stat= s' in between. Thing is that even on primary there are already some edge cases that it han= dles explicitly (eg. the create-drop-create case where on the second 'create' th= e old stats entry hasn't been removed yet). If the create-drop-create has special logic= to handle the case that the old entry still exists, why wouldn't the create-drop-drop= case have the special handling as well? Andres, would you be able to chime in on this? -Floris