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 1vRwT4-00BGrh-2K for pgsql-hackers@arkaria.postgresql.org; Sat, 06 Dec 2025 17:53:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vRwT2-00C9Hv-2V for pgsql-hackers@arkaria.postgresql.org; Sat, 06 Dec 2025 17:53:13 +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 1vRwT2-00C9Hm-0y for pgsql-hackers@lists.postgresql.org; Sat, 06 Dec 2025 17:53:12 +0000 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vRwSz-003TdP-39 for pgsql-hackers@postgresql.org; Sat, 06 Dec 2025 17:53:11 +0000 Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-640ca678745so5521333a12.2 for ; Sat, 06 Dec 2025 09:53:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765043589; x=1765648389; darn=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=OvUU0ct4B9FKbRkj8l/UFQQRhxpG/VmglFfwMEHJjAE=; b=IHfJAwHC8vIkhgvL+rZnuuKynaYGawQuwoQKq3y2CX+2/Nx+9GHx6I8x65QgSDkTzo pOVz1YO+qmFnbSB9I3bUH4TCsP4Cl+pUIIlxo4ng4sssq1XVn3ih06/wVUVv9gEHzqVg 8011QjZrsPS6XtlxgYkPzWxT4cjozvck3oKaOMmNvtLj/4gm9fshnpICNdVjsJeG5KEm T0px62hfXF79yGe16z1Uv3TpysUGR6H4Vt3lXC/Y5jB9MBn/RA2CAt0xo8LC/JPdqN49 942ywueRhipY3Brb2C5btzLj2qSgT3PGmieCsYCyStUDYYBa0mOcr/MS84tZkj3yHbUG AVig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765043589; x=1765648389; 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=OvUU0ct4B9FKbRkj8l/UFQQRhxpG/VmglFfwMEHJjAE=; b=qXRMO/zrksd03H/Wf0UaQ1uM0Ah+f+OZizIFa3U/mGOA4niQD7FSNWvBpAn94Zy05E 38ALovqFonfLpStCURXU6Iq5dJ+W5cRyTxIxzUrPjWdByE1VQjm8XA78RM/t1+rLftcu YWA87e9kjlLvxoBRY5nqCeDO2hdFnLlMKjnuEVvdmBew7DxjrQrMv/Qp5cd/Cbb5fJl2 iI4vkCR4lMgc1XgZ0lbbROXpuBfAJ9ZxqF7iibOp7BtL+Jzhe4Zd9ezXR7xcHbQ+1xaE J5kxVRmmYHUruMnZNo1zIgtCJwdLo3IkRxwxSzKHJFWODX0H+k+R3OY0J3ANawCyqC3o +o+g== X-Forwarded-Encrypted: i=1; AJvYcCX2S1t4vD4EGEjGSUFVyuzajlz1GuNiGCAb1okqyFW8qjrRt04pybXzLENzSx1YIglOMis/Ws9MIGf5qsJO@postgresql.org X-Gm-Message-State: AOJu0YwFNN1dMElsGZNeEOYDjbRg+s9nCZlVRgJ0IIyYHt2D63y+qV/r lSuD7HLX3VlloNs4dYakFPKP+azkCIeciodcdkxICocp4rmxlJhkhYeU2j5V7yPKwZxvg+H9xB0 YqUPlISdix4+FLEZ7i2CxU8LHKkGZC5M= X-Gm-Gg: ASbGncsW0euq3MqhPfyeqgcabi5TJa+UhocLldXPErfcNZLzdAI5G52ZEy9yLNGm94u KEHavcpn8Nb0mlOqfYKhkCtym1MV4Vez5ejSAHRty/pPf5/zF834XoqtktSlZ58ql5/hUgFzduF 5SjL3C+ehkXxInhXSyGhaShJuJkAwAMtRMsTh2jZfjswjvXVzEMpkddwM0ItM/6eqaHNzszUGMe RmDPJDuK56jzwzoQs4/vozLoZ6upHGc0OaHesbMzu6vvmv+f06v15LCpceQWAl7xCeqemE= X-Google-Smtp-Source: AGHT+IFmZQLbJ6+6gDFr/mFQ10Ato5No4st2GuofPMqZEQSTYQa7J5ujk3TpnSP9wCjLuaYb6dgpMtCIsd8RXEjLY4Q= X-Received: by 2002:a17:907:3fa3:b0:b77:2269:8df0 with SMTP id a640c23a62f3a-b7a2433111cmr321512266b.28.1765043588905; Sat, 06 Dec 2025 09:53:08 -0800 (PST) MIME-Version: 1.0 References: <29f9e7abc90c3a4fe4a44026141c0d6c@oss.nttdata.com> <95850ce1-2d5e-4271-92ea-c2a02e36b303@vondra.me> In-Reply-To: From: Naga Appani Date: Sat, 6 Dec 2025 11:52:57 -0600 X-Gm-Features: AQt7F2r5-GfOrHhpz_CwqR7r4MzUIGRpmZcR-sz2WeSo3NMWnEVks9K2GB68wPU Message-ID: Subject: Re: [Proposal] Expose internal MultiXact member count function for efficient monitoring To: Ashutosh Bapat Cc: Tomas Vondra , Xuneng Zhou , torikoshia , Michael Paquier , Kirill Reshke , pgsql-hackers@postgresql.org 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 Hi Ashutosh, Thanks for the review! I agree - comparing the exposed members_size against the documented thresholds is sufficient for monitoring purposes. This aligns with the approach taken in v11: exposing the current usage in a way consistent with other PostgreSQL counters (e.g., XIDs, OIDs), without introducing user-visible remaining-capacity calculations whose behavior is inconsistent and difficult to interpret externally. In the same spirit, I removed oldest_offset: as we discussed, it is internal and does not provide an actionable signal to users. If this addresses the concerns raised so far, I would appreciate consideration in moving v11 forward for commit. On Mon, Nov 10, 2025 at 12:13=E2=80=AFAM Ashutosh Bapat wrote: > > On Wed, Nov 5, 2025 at 6:43=E2=80=AFAM Naga Appani wr= ote: > > > > Understanding > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > Based on reading the relevant parts of multixact.c and observing the ru= ntime > > behavior, both approaches seem to run into limitations when trying to d= erive a > > =E2=80=9Cremaining members=E2=80=9D value outside the backend. I may be= missing details, but the > > behavior I observed suggests that a reliable computation might require > > duplicating > > several internal mechanisms, including: > > - wrap-aware offset comparison > > - SLRU page and segment alignment rules > > - SetOffsetVacuumLimit=E2=80=99s segment recalculation > > > > Without accounting for those, the derived numbers behaved inconsistentl= y across > > tests, sometimes staying at 0 until a large jump, and in other cases in= creasing > > between exhaustion cycles. This seems broadly consistent with your conc= ern that > > simple arithmetic on these counters does not match how the backend dete= rmines > > wraparound risk. > > > > To be clear, this interpretation is based only on what I could infer fr= om the > > code and testing, and I may not be capturing the entire picture. But fr= om what I > > observed, a user-visible =E2=80=9Cremaining members=E2=80=9D metric doe= s not seem > > straightforward > > without exposing or replicating backend logic. > > Right now MultiXactOffsetWouldWrap() assesses if the given distance is > higher than the permitted distance between start and boundary. I think > we could instead change it to report the permitted distance based on > start and boundary; use it to report remaining space (after > multiplying it with bytes per member) and also use it to assess > whether the required distance is within that boundary or whether we > need a warning. But ... > On Sat, Oct 18, 2025 at 4:48=E2=80=AFPM Tomas Vondra wr= ote: > > > > 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 function exposes the number of existing members and the amount of > space they consume (members_size). The documentation mentions space > related thresholds 10GB and 20GB. Isn't comparing members_size to > these thresholds enough to take appropriate action? If so, we could > report the difference between these respective thresholds and > members_size as a metric of space remaining before a given threshold > is triggered. Best regards, Naga