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 1vILA0-004zWh-PT for pgsql-hackers@arkaria.postgresql.org; Mon, 10 Nov 2025 06:13:52 +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 1vIL9y-00EIdb-5E for pgsql-hackers@arkaria.postgresql.org; Mon, 10 Nov 2025 06:13:50 +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 1vIL9x-00EIdR-Sh for pgsql-hackers@lists.postgresql.org; Mon, 10 Nov 2025 06:13:49 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vIL9v-006vmW-29 for pgsql-hackers@postgresql.org; Mon, 10 Nov 2025 06:13:49 +0000 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-477549b3082so23496605e9.0 for ; Sun, 09 Nov 2025 22:13:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762755226; x=1763360026; 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=yfpeTvdFY1V+K+I3rlxC6DbPFljBJtlc3A4X0TH8CW4=; b=Q8W6X6XVpChrOHoxhzpdGLT+YSclLnenJsMPJVt7P7DaHKvp3nrjesJRkvxVdl5Zqz 2nJEIere0DGW0wmIxo7QlvnRJb1IejVif+JbfDDNSB9FoZg+7L5QCDd/ejVEm+0e7ouf gMHxCUUdQgzlNmzVYXME3bg0/YDOblI5VHU8CkmV9W4e8F/LL9QHS+P0zDlG6InPg0n5 +MLn98LFgva9CXRJ46m8IEdM4VCZGQ+A9fkNrabQgX8FlGZUmzeOns1/mogoq9QD1oBo PwkJi9Y+4GwSHz3wVE3Ixbuel2EVqLhGa9StMKnZ/Eqym/ILEem0RthYRpD8DfgvFZXw M8tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762755226; x=1763360026; 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=yfpeTvdFY1V+K+I3rlxC6DbPFljBJtlc3A4X0TH8CW4=; b=qJut5FeakowOtxMPvWw9oPljxb8pH6TzZ4exWV24EtB695kvZadhzwrmUllb81V/8t GqhnmUzOwa8l9XMA8msofMVSiLlrJCb1/noisZCYQu4e4QSgIO9sBxLTT29qB6u8wA+v km/wnLPu18a4ap5xoPSKKiWT/Mvoxsq9Gq9rCu/QNPVzDFSPi2yZ8UPEBaXbYu008C6S NgaV/RhO1uV0TxHMj/KdIq5yyDDi+GH5Mpqj9+ysdnWBm74WBNV3SUPZ82gSAk3JkawA eOL0EWCoXdl/9ma+qtlp76BlGbEjsub8EPnO5y+T4k/vXQco3w5HEA7nDUlmyO/x1EV1 DfHQ== X-Forwarded-Encrypted: i=1; AJvYcCXOUJKzfXYXF1tFHWnSKxaRFItHacjPHY17lBi1tKGDkPWfIbX6ibjVsOQaegq1HIGyNR5Xz4qNe/T8iScj@postgresql.org X-Gm-Message-State: AOJu0YwPiPPIgyxzEwNLi/f4vGJZYPeFLsWvKolK9ykNXd2Rz85uNgii MMtdLNO9xgJ2pq0jJ81I8LGxIBE986Ei7HWkBg6k5hHDCy+6mcPir3ywExGDSO9uWSgi/+2RJRL a8+pOPxLK43cLDtf3zdVMu3KuibXgU8I= X-Gm-Gg: ASbGnctBCs0Rw/RB4geV191JWTY3GOqhXCagyX8jmYC7r9PApK7IimvWHa6ILZ1juyG z5dZTgEcOBR39zRvu0x0Ylnu1tICqKgCmvNzlQuCntWtU+cUvLwztongqZvwQgtMk/84Lbcfkp2 dWSuHnRMU+ZDXLwp6t+QQafLnJQ+xTl/Fea+bprEjY2c3MvTM/WH/hwBRR+yUifOC/LYBo9pkFO MqELvUE5Wii8VeMRtc/YHlOtfnlniRrgEtIE9MyairepC4z5kvoUgIXnbgpgg== X-Google-Smtp-Source: AGHT+IF7PfUXhodlSLxEBQnWXb6K4HS7vExLY8gGcIsIsfbI+mMx7KpdNaYJPufPHv9AreJx2iXpeRu3BzMe4/SjoXA= X-Received: by 2002:a05:600c:46ce:b0:46e:4b79:551 with SMTP id 5b1f17b1804b1-47773288bbfmr68738735e9.31.1762755225839; Sun, 09 Nov 2025 22:13:45 -0800 (PST) MIME-Version: 1.0 References: <29f9e7abc90c3a4fe4a44026141c0d6c@oss.nttdata.com> <95850ce1-2d5e-4271-92ea-c2a02e36b303@vondra.me> In-Reply-To: From: Ashutosh Bapat Date: Mon, 10 Nov 2025 11:43:33 +0530 X-Gm-Features: AWmQ_blHYReDQYkCpGy1ctaggFnbJr39ZC3rF_xiaLZSwmN_iRLlM_-E4nWttM0 Message-ID: Subject: Re: [Proposal] Expose internal MultiXact member count function for efficient monitoring To: Naga Appani , Tomas Vondra Cc: 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 On Wed, Nov 5, 2025 at 6:43=E2=80=AFAM Naga Appani wrot= e: > > 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 runt= ime > behavior, both approaches seem to run into limitations when trying to der= ive a > =E2=80=9Cremaining members=E2=80=9D value outside the backend. I may be m= issing 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 inconsistently = across > tests, sometimes staying at 0 until a large jump, and in other cases incr= easing > between exhaustion cycles. This seems broadly consistent with your concer= n that > simple arithmetic on these counters does not match how the backend determ= ines > wraparound risk. > > To be clear, this interpretation is based only on what I could infer from= the > code and testing, and I may not be capturing the entire picture. But from= what I > observed, a user-visible =E2=80=9Cremaining members=E2=80=9D metric does = 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 wrot= e: > > 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. --=20 Best Wishes, Ashutosh Bapat