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 1sJz9R-007hK5-T0 for pgsql-hackers@arkaria.postgresql.org; Wed, 19 Jun 2024 17:31:18 +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 1sJz9P-003QV3-C5 for pgsql-hackers@arkaria.postgresql.org; Wed, 19 Jun 2024 17:31:16 +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 1sJz9O-003QUL-Sn for pgsql-hackers@lists.postgresql.org; Wed, 19 Jun 2024 17:31:15 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sJz9N-002Vab-5Y for pgsql-hackers@lists.postgresql.org; Wed, 19 Jun 2024 17:31:14 +0000 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-3645e9839b3so20754f8f.3 for ; Wed, 19 Jun 2024 10:31:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bowt-ie.20230601.gappssmtp.com; s=20230601; t=1718818271; x=1719423071; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Vv2sEO2zsOzj5zBoOWX2ebyIQ4mOAXoXOj5Xsdb2Fx0=; b=p5x+3wp7XY2lYT6HU7WrOFvbkPtHGjm6L492cmxv6EnPWlrp7Ykuh1t0MFmg8Wz0Dz WUc96MTUiPIQRhsBy0loC3Jq97ertn0d+UOrYB0U5xCt0Ojm0CngTenf9aBODjBVKeXL JSpKT78R/JL1Kqp/9YjD7VT1IORTGWkgLLFp/P8q671FbvzzWYqf1z3QEv4/1LQju/zw CbAlXfj26GoGiqt/pIZyluHWT6P6Pnpoi6cxlr0tv3hgm8+t8dezock/D42XNcD4buZI ZcI0cat5xW7WxTQSUWOIbePDrr2zPQ00DeD+h9L6tvazsQ9C/eNMTaQZYbZb6vffLW9a /gqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718818271; x=1719423071; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Vv2sEO2zsOzj5zBoOWX2ebyIQ4mOAXoXOj5Xsdb2Fx0=; b=Z6wXxXljJ9E6ghfC+hqIb1oBimE8G0MTLWFyp6wlEMlwRg8f+73OZYiglP/vLk8Ulx ZSCNZtusiBV33Rzcy1F83Mre7ucF83HipNzOyjr27Fw9Wz+PSo31xIL33zJgvIrrqnvN S9brpYIxHax46xctX1/WYSnDw/XS77E6xCk2/FFi9Aq7+kvYrY0xEZ9qlEKwejw3FlcP oe8n3ApiRIuMkXtWEEMnKbdRzF1MgAnzi1mtITdKeUjzIhtcG2EFiDIrrPsDkUf8XqUn zPb2DmaIb8VIRM5xqniCvJk57YEkipwaQ4QaiDxosFoh3CPhKCpqmvhQS4hI3kE0Pe0m Djxg== X-Forwarded-Encrypted: i=1; AJvYcCUp845/19HTQFzt1iNU4aJbvtvd1kTO02UDi28bz/vhmwlp7YTHDsNYRjCtMxRr2n8chyRfd35IlJGg+8/4RCQ5wQkFCf/JpJmgup5kcfUUYhmg X-Gm-Message-State: AOJu0Yzvo5IpAtT1zcRNW+ltij3X8YXxMuQXUlG98rOn6+AHnBa5gKXp D7bmH/TE0kuFJZEydx1pp+4lVm0uVMWcGrrv5QrFVo46ZslC+ZMylA1yAmmQgcHt7PUq3ZxE/fV E47CW17foIHdeRhH4AdU+z/AfgViTnJUP+JVj3A== X-Google-Smtp-Source: AGHT+IHoMKSk11rz7/Ra5qcYy+6QGyfkJSlqgeARYbWwI331telduDfIeIXT/cg7RPXj3KvmBLquG2VuZwQdnWM2i80= X-Received: by 2002:a05:6000:104:b0:362:c7b3:764c with SMTP id ffacd0b85a97d-363192ce1bbmr2337543f8f.48.1718818271033; Wed, 19 Jun 2024 10:31:11 -0700 (PDT) MIME-Version: 1.0 References: <21ece835-b671-4656-9f35-008b9f355034@postgrespro.ru> <0e3466eb-ea42-47a6-8662-ca94b95f5a66@postgrespro.ru> In-Reply-To: <0e3466eb-ea42-47a6-8662-ca94b95f5a66@postgrespro.ru> From: Peter Geoghegan Date: Wed, 19 Jun 2024 13:30:44 -0400 Message-ID: Subject: Re: Maybe don't process multi xmax in FreezeMultiXactId() if it is already marked as invalid? To: Yura Sokolov Cc: Maxim Orlov , "Anton A. Melnikov" , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Jun 19, 2024 at 1:00=E2=80=AFPM Yura Sokolov wrote: > So it is quite different code paths, and one could not be used > to decline or justify other. The point is that we shouldn't need to rely on what is formally a hint. It might be useful to use the hint to decide whether or not freezing now actually makes sense, but that isn't the same thing as relying on the hint (we could make the same decision for a number of different reasons). > More over, certainly test on HEAP_XMAX_INVALID could be used > there in heap_prepare_freeze_tuple to set > freeze_xmax =3D true; > Why didn't you do it? You might as well ask me why I didn't do any number of other things. I actually wrote a patch that made FreezeMultiXactId() more aggressive about this sort of thing (setting HEAP_XMAX_INVALID) that targeted Postgres 16. That worked by noticing that every member XID was at least before OldestXmin, even when the MXID itself was >=3D OldestMxact. That didn't go anywhere, even though it was a perfectly valid optimization. It's true that FreezeMultiXactId() optimizations like this are possible. So what? > 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. In what sense is there an inconsistency? I think that you must mean that we need to do the same thing for the !MultiXactIdIsValid() case and the already-HEAP_XMAX_INVALID case. But I don't think that that's any meaningful kind of inconsistency. It's *also* what we do with plain XIDs. If anything, the problem is that we're *too* consistent (ideally we *would* treat MultiXacts differently). > Yes, we changed completely different place mistakenly relying on > consistent reaction on this "hint", and that leads to bug in our > patch. Oooops! > > 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? This is the first email that anybody has used the word "optimization". We've been discussing this as if it was a bug. You introduced the topic of optimization 3 seconds ago. Remember? > If we couldn't rely on hint, then hint is completely meaningless. We don't actually trust the hints in any way. We always run checks inside heap_pre_freeze_checks(), rather than assuming that the hints are accurate. --=20 Peter Geoghegan