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 1sI1d2-00CGEv-Lr for pgsql-hackers@arkaria.postgresql.org; Fri, 14 Jun 2024 07:45:45 +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 1sI1d0-00EwJD-3o for pgsql-hackers@arkaria.postgresql.org; Fri, 14 Jun 2024 07:45:42 +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 1sI1cz-00EwIm-Ls for pgsql-hackers@lists.postgresql.org; Fri, 14 Jun 2024 07:45:42 +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 1sI1cx-001b7c-PN for pgsql-hackers@lists.postgresql.org; Fri, 14 Jun 2024 07:45:41 +0000 Received: from [172.30.1.222] (unknown [172.30.1.222]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: a.melnikov@postgrespro.ru) by mail.postgrespro.ru (Postfix/587) with ESMTPSA id 700FEE20FD8 for ; Fri, 14 Jun 2024 10:45:38 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1718351138; bh=/GWX6zalB1/0rStJPG80Obxc979+5aubSYSOmuSdVmw=; h=Message-ID:Date:User-Agent:To:From:Subject:From; b=nfs+A56ppc/HpvKGQg0tTzEaP5NaVs4FDETdPNLVRTi+4OIVQ8Lu4ILlnw6g7iRnU FfIviRakhsJgbWq8JOl/qkZeF4+cwc5aaPvwxqUdH1wQfgwxse7t0CdyVKsKcNAgDM 1NsRUVrawqLfQeZDaLXXI7nY3OG3LzIDLDHkx7bj1Fd3xriNkp+erFggMwWT3YRalG E79WQb3Xpi1S3EQEilvZbEArPwORI074MVpXExwGQj649p+MZBpQIeJ+dd2Tlpbmo1 fkYQqZ6LYFmDIqvHyADQtZ3ljZM6Cjou7lWxZWKswCUvQN40fVPvsAaQUlZSXLsyJ8 sHG+C5fk1QGsQ== Message-ID: <21ece835-b671-4656-9f35-008b9f355034@postgrespro.ru> Date: Fri, 14 Jun 2024 10:45:38 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: PostgreSQL Hackers From: "Anton A. Melnikov" Subject: Don't process multi xmax in FreezeMultiXactId() if it is already marked as invalid. Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-KSMG-AntiPhishing: NotDetected, bases: 2024/06/14 07:04: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/06/14 06:58:00 #25597075 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 Hello! The src/backend/access/heap/README.tuplock says about HEAP_XMAX_INVALID bit that "Any tuple with this bit set does not have a valid value stored in XMAX." Found that FreezeMultiXactId() tries to process such an invalid multi xmax and may looks for an update xid in the pg_multixact for it. Maybe not do this work in FreezeMultiXactId() and exit immediately if the bit HEAP_XMAX_INVALID was already set? For instance, like that: master @@ -6215,6 +6215,15 @@ FreezeMultiXactId(MultiXactId multi, uint16 t_infomask, /* We should only be called in Multis */ Assert(t_infomask & HEAP_XMAX_IS_MULTI); + /* Xmax is already marked as invalid */ + if (MultiXactIdIsValid(multi) && + (t_infomask & HEAP_XMAX_INVALID)) + { + *flags |= FRM_INVALIDATE_XMAX; + pagefrz->freeze_required = true; + return InvalidTransactionId; + } + if (!MultiXactIdIsValid(multi) || HEAP_LOCKED_UPGRADED(t_infomask)) With the best regards, -- Anton A. Melnikov Postgres Professional: http://www.postgrespro.com The Russian Postgres Company