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 1vA4wq-00DSaZ-NT for pgsql-hackers@arkaria.postgresql.org; Sat, 18 Oct 2025 11:18:08 +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 1vA4wn-007YVV-QY for pgsql-hackers@arkaria.postgresql.org; Sat, 18 Oct 2025 11:18:04 +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 1vA4wn-007YVM-CJ for pgsql-hackers@lists.postgresql.org; Sat, 18 Oct 2025 11:18:04 +0000 Received: from relay9-d.mail.gandi.net ([217.70.183.199]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vA4wj-002suU-2I for pgsql-hackers@postgresql.org; Sat, 18 Oct 2025 11:18:03 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id B0BEB441FF; Sat, 18 Oct 2025 11:17:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vondra.me; s=gm1; t=1760786279; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rR2LVtFfUCiLoL0LiMW84aKVRp6BFVSBtt0qFwEngC8=; b=OcXyyHw6iGlkI2Vw8u+boT+w6DHharXMH9wiFmo4RybvOEpfclxi5aMz6YOkI69kyMKjZ/ njGDD0HwTil7c6gOhA22SlFETZds6nSoHgl6WN4LmJTeJ7fz3M7pD/1Q/zg+D27YiMXp6G 6rpJIRlMMUjN9C3prwOideF4Euw0vA1TELfr8qglAnfVAlJ2GHxvpm4gvCbuuRUPZSzts/ BDwd5JGAXTstJb+JM7sbHrKyK2JQCBw5zwNweMj/8eIu4k+kdBrdMtvVLUInq8Nn+MmzQ9 O32tMGpnvesTfOgFQFSH99LGaFx9tXZqKK/oIuFwj6pdIwqe1uQfuxRekTpW+g== Message-ID: <95850ce1-2d5e-4271-92ea-c2a02e36b303@vondra.me> Date: Sat, 18 Oct 2025 13:17:57 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Tomas Vondra Subject: Re: [Proposal] Expose internal MultiXact member count function for efficient monitoring To: Xuneng Zhou , torikoshia , Naga Appani Cc: Ashutosh Bapat , Michael Paquier , Kirill Reshke , pgsql-hackers@postgresql.org References: <29f9e7abc90c3a4fe4a44026141c0d6c@oss.nttdata.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-GND-Sasl: tomas@vondra.me List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Thanks for working on this. I'm wondering if this is expected / could help with monitoring for "space exhaustion" issues, which we currently can't do easily, as it's not exposed anywhere. This is in multixact.c at line ~1177, where we do this: if (MultiXactState->oldestOffsetKnown && MultiXactOffsetWouldWrap(MultiXactState->offsetStopLimit, nextOffset, nmembers)) { ereport(ERROR, ... } But I'm not sure the current patch exposes enough information to calculate how much space remains - calculating that we requires offsetStopLimit and nextOffset. The stopLimit could be calculated from oldest_offset, which the patch returns. It's not quite trivial. It depends on BLCKSZ through MULTIXACT_MEMBERS_PER_PAGE, and various other internal constants. It's tempting to hardcode those into monitoring scripts, which then gets broken in subtle ways with custom builds or if we change something (which for multixacts we can). And I don't think the patch exposes nextOffset, right? So AFAICS we can't actually calculate the remaining space. Could it either return nextOffset, or maybe actually calculate and return the remaining space? And perhaps the "total" space, so that it's possible to calculate what fraction of the space we already consumed. I'm actually not entirely convinced we should be exposing the raw internal information this patch aims to expose. Because a lot of that feels like an internal implementation detail, and it's going to be hard to interpret .... Knowing num_mxids / num_members or members_size is nice, but how would I judge how far the system is from hitting some threshold or hard limit? Is there some maximum number of mxids/members that we could return? Or something like that? Similarly for oldest_multixact / oldest_offset. How useful is that without knowing the "next" value for each of those? Or am I missing something obvious? regards -- Tomas Vondra