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.96) (envelope-from ) id 1vMQ4l-009H0Z-08 for pgsql-hackers@arkaria.postgresql.org; Fri, 21 Nov 2025 12:17:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vMQ3k-0079e7-0M for pgsql-hackers@arkaria.postgresql.org; Fri, 21 Nov 2025 12:16:16 +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.96) (envelope-from ) id 1vMQ3j-0079dw-29 for pgsql-hackers@lists.postgresql.org; Fri, 21 Nov 2025 12:16:16 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vMQ3b-000gzk-1h for pgsql-hackers@lists.postgresql.org; Fri, 21 Nov 2025 12:16:14 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-477619f8ae5so11586705e9.3 for ; Fri, 21 Nov 2025 04:16:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763727367; x=1764332167; 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=VneV8tJnLIAW/gOUzXubbKq0datYuDw5wYjw6cn04A8=; b=I45oGJplF6nZmdMIJmZbivdp7ZUKdBhBNsnxuMfL+9taJ+RH5w19+L/Q307LzYeU7P Ghor/1CvtUBfXdDgxVg286cp36SvWdz14jEGGTe18oj+coPDjCyoMOCpxclj1NqSElFP 3vGhfnlcMD5I8li0W/fd8OM/TikIIsZcrx7dhzqA5kQhrflMxDQiI8pXzeitDxBouOxZ 0oDAO6Gqzw80vESvEjQVTxFPJIXs9YFxkZczKY0q60qH1KsuYz0tCg4qvo4wJK4d26NN EwCnRkwBblNEPY2YldfyLoDWu1Nn7qn8qBzdbw57cultWo1RbTi2DXO/tjetL53jyhEc euYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763727367; x=1764332167; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=VneV8tJnLIAW/gOUzXubbKq0datYuDw5wYjw6cn04A8=; b=CgC3HCwYikXCEJAaabRDwXV6VkUN48DTzDmq4of5DttCSYMenhxTkSUrzNlvxfPk2P EbjPqAa0unZJ5/7qIlcr3M4nZC2gIcW5yWqid65KVUjDRLSK1rpwlVKYtLxKsrnkOX+l liRe4CW4C9YQouYHNDzhYxKa1EO6brD/NqjHdbYynk4ah4lFl79JDaIP2x8L/WHz4/Ah KjjN4w3GRl3IOiZj7BgvS1bl70ldO0uFHrmfIFZD5EoOP7ApxWNPJnv1LixdG1GMq3Wy 5ceJ89U07p+Yr+/ZL4AZsdglv2+s/ndu6GyMwEZ3wdaT0+XdnWoQsYQF1RnXvv9qckTF 3tow== X-Forwarded-Encrypted: i=1; AJvYcCWxX0MUA3ooBf7GblDx7mGJuPsyXa732m8xxHC9kXKP0++UBjYUnzXNeVYC7t8O8xi7elabZZPE/WwVShXn@lists.postgresql.org X-Gm-Message-State: AOJu0Yw6kMCXUHOOkss9hkUmf3MW0qqta62nCPcs37ZE0nycZmJTQ5iw 08b4OFKoUk4DaLkH//s07CEdMby2wj5qXLlEsJL2vj9K5ieQt6+iNyUocObtNAEuvufUQ/Pf2gk sILI6WiHcNBX1VkBELjIVFvcJUP6nx5I= X-Gm-Gg: ASbGncsVUSnFoJwQhsV6UU8rbS06VfZ2UrQb7ospuCoE65Yfhjl4YWj0PpoMpxTN+OJ ylVHyKBfv+rkwu8RWanMVeJTfelgNZAEk0z9c3RFKcabKaWbmWeL49Oix8907RWcO0chN2LUm81 BHKORTlvftD0MkZGyDBWoO1bdBuEg4VUDw8za85Mi2ux9wuxqtzN1dcjwbPr8JE1XhDrLsXjZ+t ED2iEYOkI+CdvzQaM9uXumdzQY+aMz3W/1d17svFWte3OqFL4/AXHjpnG/xLoHEBjI12qvC X-Google-Smtp-Source: AGHT+IHfp4MaBYkM8S2zpUxsn/8t71QLlHaVp+SL4+c7EjGHarUddIdqBGRfUOzdTqkW60Ovr/l6QuxeNLAAxf1odGU= X-Received: by 2002:a05:6000:2dc5:b0:42b:3023:66a6 with SMTP id ffacd0b85a97d-42cc1d35666mr2244179f8f.40.1763727366532; Fri, 21 Nov 2025 04:16:06 -0800 (PST) MIME-Version: 1.0 References: <4535f3aa-3220-4760-b1f5-2bc91f248e03@iki.fi> <2bc58592-9d74-4af0-bdd1-1a88e8683f7c@iki.fi> <36531c0e-292c-409d-bbc7-a252cf6e910a@iki.fi> <54aa8f65-f0e4-4464-b543-e0399c1cab1e@iki.fi> <4a9dda70-0af7-41a4-9636-b168f2fc48ef@iki.fi> <46cc45e9-fddd-44bc-bcb3-96889aafd921@iki.fi> In-Reply-To: <46cc45e9-fddd-44bc-bcb3-96889aafd921@iki.fi> From: Ashutosh Bapat Date: Fri, 21 Nov 2025 17:45:54 +0530 X-Gm-Features: AWmQ_blfUa-dTiFSuOksYjPV96pg7dbYUTpjml3_s2hfW5-fIzyn_8QDSDTp6q8 Message-ID: Subject: Re: POC: make mxidoff 64 bits To: Heikki Linnakangas Cc: Maxim Orlov , Alvaro Herrera , Alexander Korotkov , wenhui qiu , Postgres 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 Mon, Nov 17, 2025 at 10:05=E2=80=AFPM Heikki Linnakangas wrote: > > Ashutosh, you were interested in reviewing this earlier. Would you have > a chance to review this now, before I commit it? 0002 seems to be fine. It's just moving code from one file to another. However, the name multixact_internals.h seems to be misusing term "internal". I would expect an "internal.h" to expose things for use within the module and not "externally" in other modules. But this isn't the first time, buf_internal.h, toast_internal.h bgworker_internal.h and so on have their own meaning of what "internal" means to them. But it might be better to use something more meaningful than "internal" in this case. The file seems to contain declarations related to how pg_multixact SLRU is structured. To that effect multixact_slru.h or multixact_layout.h may be more appropriate. There are two offsets that that file deals with offset within pg_multixact/offset, MultiXactOffset and member offset (flag offset and xid offset) within pg_multixact/members. It's quite easy to get confused between those when reading that code. For example, it's not clear which offset MultiXactIdToOffset* functions are about. These functions are calculating the page, entry (within the page) and segment (of page) in pg_multixact/offset where to find the MultiXactOffset of the first member of a given mxid. Thus returning offset within offset. I feel they should have been named differently when the code was written. But now that we are moving this code in a separate file, we also have an opportunity to rename it better. I think MXOffsetToMember* functions have better names. Using a similar convention we could use MultiXactIdToOffsetOffset*, but that might increase confusion. How about MultiXactIdToOffsetPos*? A separate .h file also looks like a good place to document how offsets are laid out and its contents and how members is laid out. The latter is somehow documented in terms of macros and the static functions. The first is not documented well, I feel. This refactoring seems to be a good opportunity to do that. If we do so, I think, the .h there will be some value in committing .h file as a separate commit. The reason why this eliminates the need for wraparound is mentioned somewhere in GetNewMultiXactId(), but probably it should be mentioned at a more prominent place and also in the commit message. I expected it to be in the prologue of GetNewMultiXactId(), and then a reference to prologue from where the comment is right now. ereport(ERROR, (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), errmsg("MultiXact members would wrap around"))); If a server ever reaches this point, there is no way but to create another cluster, if the applications requires multi-xact ids? We should also provide this as an errhint(). if (nextOffset + nmembers < nextOffset) :). I spent a few seconds trying to understand this. But I don't know how to make it easy to understand. In ExtendMultiXactMember() the last comment mentions a wraparound /* * Advance to next page, taking care to properly handle the wraparound * case. OK if nmembers goes negative. */ I thought this wraparound is about offset wraparound, which can not happen now. Since you have left the comment intact, it's something else. Is the wraparound of offset within the page? Maybe requires a bit more clarification? PerformMembersTruncation(MultiXactOffset oldestOffset, MultiXactOffset newOldestOffset) { ... snip ... - segment +=3D 1; - } + SimpleLruTruncate(MultiXactMemberCtl, + MXOffsetToMemberPage(newOldestOffset)); } Most of the callers of SimpleLruTruncate() call it directly. Why do we want to keep this static wrapper? PerformOffsetsTruncation() has a comment which seems to need the wrapper. But PerformMembersTruncation() doesn't even have that. MultiXactState->oldestMultiXactId =3D newOldestMulti; MultiXactState->oldestMultiXactDB =3D newOldestMultiDB; + MultiXactState->oldestOffset =3D newOldestOffset; LWLockRelease(MultiXactGenLock); Is this something we are missing in the current code? I can not understand the connection between this change and the fact that offset wraparound is not possible with wider multi xact offsets. Maybe I missed some previous discussion. I have reviewed patch 0002 and multxact.c changes in 0003. So far I have only these comments. I will review the pg_upgrade.c changes next. --=20 Best Wishes, Ashutosh Bapat