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 1sJyfi-007fFT-Op for pgsql-hackers@arkaria.postgresql.org; Wed, 19 Jun 2024 17:00:35 +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 1sJyfg-002nZX-Dd for pgsql-hackers@arkaria.postgresql.org; Wed, 19 Jun 2024 17:00:33 +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 1sJyff-002nVQ-Vg for pgsql-hackers@lists.postgresql.org; Wed, 19 Jun 2024 17:00:32 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sJyfe-002V8D-68 for pgsql-hackers@lists.postgresql.org; Wed, 19 Jun 2024 17:00:32 +0000 Received: from [192.168.27.71] (unknown [93.174.131.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: y.sokolov@postgrespro.ru) by mail.postgrespro.ru (Postfix/465) with ESMTPSA id 500C5E2104D; Wed, 19 Jun 2024 20:00:28 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1718816428; bh=aFrsvDloccFBBv5IFuHHFQg6hiWhBu5Z0EeMXH8UAAM=; h=Message-ID:Date:User-Agent:Subject:To:Cc:References:From: In-Reply-To:From; b=ud3+AXmnfoaSHyIgUKWGg2BjaB8dCVxxjtUR7uqRUPxnlRgi9ivqys49WZoh8LbXs DIe178lQZDYSIsu4xpWfi15lr3/OyOicOiX7Pzh6au7N1EX+0bEAJmZLmMBeZ0A6Zi bnsSLPDQ/imhBmJZw+xaFJS8Fl4kJMBCOc7EkzVbsrqJRYDMAKgUVOxxKOMgOFgYXq WwpUY7xZAz8VOfCw4aQ4hHO1Ea0PJOi469FWZOFENN1xesUalV7KJ+U3g3adtnOA4J uIOc6gAjD3TIv7K0cwKxMTEmF3TuY3iOoDGsztG5/ZUX0+FogYajjTF+2VlNbM7nnx Tuws2CinAYgXA== Message-ID: <0e3466eb-ea42-47a6-8662-ca94b95f5a66@postgrespro.ru> Date: Wed, 19 Jun 2024 20:00:28 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Maybe don't process multi xmax in FreezeMultiXactId() if it is already marked as invalid? To: Peter Geoghegan , Maxim Orlov Cc: "Anton A. Melnikov" , PostgreSQL Hackers References: <21ece835-b671-4656-9f35-008b9f355034@postgrespro.ru> Content-Language: en-US From: Yura Sokolov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-KSMG-AntiPhishing: NotDetected 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/06/19 10:38:00 #25669005 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 18.06.2024 18:47, Peter Geoghegan пишет: > On Tue, Jun 18, 2024 at 10:29 AM Maxim Orlov wrote: >> Maybe, I'm too bold, but looks like a kinda bug to me. At least, I don't understand why we do not check the HEAP_XMAX_INVALID flag. >> My guess is nobody noticed, that MultiXactIdIsValid call does not check the mentioned flag in the "first" condition, but it's all my speculation. > > A related code path was changed in commit 02d647bbf0. That change made > the similar xmax handling that covers XIDs (not MXIDs) *stop* doing > what you're now proposing to do in the Multi path. I don't agree commit 02d647bbf0 is similar to suggested change. Commit 02d647bbf0 fixed decision to set freeze_xmax = false; xmax_already_frozen = true; Suggested change is for decision to set *flags |= FRM_INVALIDATE_XMAX; pagefrz->freeze_required = true; Which leads to freeze_xmax = true; So it is quite different code paths, and one could not be used to decline or justify other. More over, certainly test on HEAP_XMAX_INVALID could be used there in heap_prepare_freeze_tuple to set freeze_xmax = true; Why didn't you do it? > > Why do you think this is a bug? It is not a bug per se. But: - it is missed opportunity for optimization, - it is inconsistency in data handling. Inconsistency leads to bugs when people attempt to modify code. Yes, we changed completely different place mistakenly relying on consistent reaction on this "hint", and that leads to bug in our patch. >> Does anyone know if there are reasons to deliberately ignore the HEAP_XMAX INVALID flag? Or this is just an unfortunate oversight. > > HEAP_XMAX_INVALID is just a hint. > WTF is "just a hint"? I thought, hint is "yep, you can ignore it. But we already did some job and stored its result as this hint. And if you don't ignore this hint, then you can skip doing the job we did already". So every time we ignore hint, we miss opportunity for optimization. Why the hell we shouldn't optimize when we safely can? If we couldn't rely on hint, then hint is completely meaningless. -------- have a nice day Yura Sokolov