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 1tJrAM-005UXS-Tq for pgsql-hackers@arkaria.postgresql.org; Sat, 07 Dec 2024 09:31:59 +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 1tJrAJ-00FQMt-Ao for pgsql-hackers@arkaria.postgresql.org; Sat, 07 Dec 2024 09:31:56 +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.94.2) (envelope-from ) id 1tJrAI-00FQMl-SG for pgsql-hackers@lists.postgresql.org; Sat, 07 Dec 2024 09:31:56 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tJrAE-001U1Q-R8 for pgsql-hackers@lists.postgresql.org; Sat, 07 Dec 2024 09:31:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1733563906; bh=F8ok93rUlFbffkz/mOK6Jax3Y+cJVw9QScJb3zOXsVU=; h=Message-ID:Date:User-Agent:Subject:To:Cc:References:From: In-Reply-To:From; b=OpFigZAl9SlvE7OKwMcX0aNE4w2DEFZ/LNE9ijbYxJeQbVeFyrFtvSzKam3hkOtcJ hEWNX+t9zHyXYGMvkAgegrasqwTVUGiKMPLoTLQ9xyRGGG4WGbBppf5q1QSXU3g9yZ SWF55vrzevXY7EJn2oWRhbMz3ZlBHNRKBIc/5nlfw909Q4m9B2SQqMPlEcIInw+S9D Z0EUB/4mnlVa9ae0HIWxH8Fm/th1ifNqbY0miJalgTO9kEUZi0WgN5cEshTnYvtlVu SlCvgBuMKZB0juayocPn9kEqsfZzh0JTZQ0KAFYTozLCUsVTRDRuTnpJE9MjkVrXC+ ikRg779pAGOrQ== Received: from [172.30.48.58] (unknown [172.30.48.58]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: a.melnikov@postgrespro.ru) by mail.postgrespro.ru (Postfix/587) with ESMTPSA id 83BE86089B; Sat, 7 Dec 2024 12:31:46 +0300 (MSK) Content-Type: multipart/mixed; boundary="------------5wkxFQWSQwLm2tUN6ROL0Iux" Message-ID: <5911c537-5665-4e93-91fa-de5465df487d@postgrespro.ru> Date: Sat, 7 Dec 2024 12:31:46 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: shared-memory based stats collector - v70 To: Bertrand Drouvot , Michael Paquier Cc: Andres Freund , "Drouvot, Bertrand" , Greg Stark , Tom Lane , Melanie Plageman , Kyotaro Horiguchi , Justin Pryzby , Thomas Munro , "David G. Johnston" , PostgreSQL Hackers References: <20220818195124.c7ipzf6c5v7vxymc@awork3.anarazel.de> <5bfcf1a5-4224-9324-594b-725e704c95b1@amazon.com> Content-Language: en-US From: "Anton A. Melnikov" In-Reply-To: X-KSMG-AntiPhishing: NotDetected, bases: 2024/12/07 08:55:00 X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.0.7854, bases: 2024/12/07 03:49:00 #26945252 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: not scanned, disabled by settings X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------5wkxFQWSQwLm2tUN6ROL0Iux Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi! On 04.12.2024 18:24, Bertrand Drouvot wrote: > Thanks! I've the feeling that something has to be fixed, see my comments in > [1]. It might be that the failed assertion does not handle a "valid" scenario. > > [1]: https://www.postgresql.org/message-id/Z1BzI/eMTCOKA%2Bj6%40ip-10-97-1-34.eu-west-3.compute.internal On 05.12.2024 08:43, Michael Paquier wrote: > It's really a case that should never be reached because it points to > an inconsistency in the interactions between the local entry cache in > a process and the central dshash it attempts to point to, so I don't > think that there is anything to change here. As Andres has mentioned, > it has a lot of value by acting as a safety guard in assert builds > without being annoying for production deployments. Thanks a lot for for the detailed clarification! Everything here became clear for me. On 05.12.2024 11:13, Michael Paquier wrote: > On Thu, Dec 05, 2024 at 07:37:27AM +0000, Bertrand Drouvot wrote: >> That said, I think that's worth to update the comment a bit (like in the >> attached?) as I think that answers a legitimate question someone could have while >> reading this code. > > Perhaps this should provide some details, like the fact that we don't > expect the server to still have references to entries that are dropped > at shutdown when writing the stats file as all the backends and/or > auxiliary processes should have done this cleanup before they are > gone. Completely agree that the original comment needs to be revised, since it implies that it is normal for deleted entries to be here, but it is not the case. On 05.12.2024 17:13, Bertrand Drouvot wrote: > Okay, attached a more elaborated comment. Looks good for me. Detailed and clear. Will help to avoid unnecessary questions when reading this code. Maybe it's worth adding a warning as well, similar to the one a few lines below in the code? Like in the patch attached? With the best regards, -- Anton A. Melnikov Postgres Professional: http://www.postgrespro.com The Russian Postgres Company --------------5wkxFQWSQwLm2tUN6ROL0Iux Content-Type: text/x-patch; charset=UTF-8; name="v2-0002-Add-warning-about-dropped-stat-entries.patch" Content-Disposition: attachment; filename="v2-0002-Add-warning-about-dropped-stat-entries.patch" Content-Transfer-Encoding: base64 RnJvbSAxYmVjYmZhMWM4NzMxNzRmNzMxMWFkNTc1NjlhNGNlOGE5ZTNhOWM4IE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiAiQW50b24gQS4gTWVsbmlrb3YiIDxhLm1lbG5pa292 QHBvc3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