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 1uuUbe-00AvHE-9c for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Sep 2025 11:27:51 +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 1uuUbd-006soy-Dp for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Sep 2025 11:27:49 +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 1uuUbd-006soq-3b for pgsql-hackers@lists.postgresql.org; Fri, 05 Sep 2025 11:27:49 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uuUba-000hds-10 for pgsql-hackers@postgresql.org; Fri, 05 Sep 2025 11:27:49 +0000 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-45b627ea685so16174555e9.1 for ; Fri, 05 Sep 2025 04:27:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757071666; x=1757676466; 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=LhmksQCJ8Ct0OP02pqUlI2xsAL5TwBBWcLo/Lg2pnSg=; b=jGOaFGJrVp3DHZUsOrFhY4jyzD9ZIEDG34WDoK+H1RZzTyqiTF0mwrINv1ZIWvVnZf TBpjjvu3BXhv/LLlxvTAUuON7KGcFbpQeK3B1vP722W8SccqCSWrY0ujpV7fpkpR3SKM itMvm5+RsCw5BbQJ5M1kEve2B94HziZkWxp3agA+i4xcInDb7VzsBFTpPOU4y1IzM64+ YX7lThTbIStQIHLnvj1vwOpSfi49ojyNxoVfnGkixRJ6oEOTbFESzSdb+Rw+RANRWvKU x1YMugFQ8pMhow6pepwXdnXMKZCXtD/qpIlqmE5MTMXNvFCEC89psohUQaZWwxtdcIgr 8QMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757071666; x=1757676466; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LhmksQCJ8Ct0OP02pqUlI2xsAL5TwBBWcLo/Lg2pnSg=; b=Eya6S/XdxZ2WfhdHcWDXD6UeootjeJwxR1Rm0W/1lxUSemounYLGdm+AajtEvnx+4y ZpisovtpTEKSl47AHV96F2NuKsckPVVLuE2Ns8w6TeP67rINZlUh0nGNPt3TpiqUP7Wz YsHTZy2MPg4JlGIhzNbDGv8meyCGp05G9COhuyTDmc3vujoOx27M0mOJaLkffftjM48d nIGEjRTqJkWBHzMYCuOHrQG/DMY6FvtAVY6iWZ3TSpRKSvkYBjwkrWW0ikIeim+hrVQG 4ud2sV1pXXkEbwQOfrC2PTCZQIXkDJ+TlqGH+7ibqS89012FW6ND9rv6+lXvghQcsjca iMDQ== X-Forwarded-Encrypted: i=1; AJvYcCURKgKNvSlbqwSK1gF85Zy0i68YZRnUZlpqqzhJDFIjK/Njw38sUgpDARUWW/zvhSQo53a+IPw2nK2eNO1y@postgresql.org X-Gm-Message-State: AOJu0YzyMAX3FQgVR004pq21gZT6mWK13ZUjPhEURyycXKCOQBjsWUE1 T/O3NfBO5QAD74R0WbBREirBhELTJgHmKRNPAd4BTHDGiy7uI5xulMflx/mwnrE2k1HdEhLW8yt SOTq0U7ljWqN2PFltLRRKvL/9rhTozFS4wQlx X-Gm-Gg: ASbGnct0amjT9FfQG+pmWXE/1riN4ihnt60lGE73mCvlHfSnJ5k74DOSeRWktV9CqP/ WBmCFEZHcMpgtrTdL92/YwKseXw2sOyIiF/i3LqcgcjjV5svJn/rqOFysJX476Ojm+VsCKW94H7 Pz+c1IsJohIED41gw0N/hmdpitWcuRPr3+e80GMtNqLBcs1+ib/elC36OtoGQEqo4FX8KEea0xT A2XA9Ooiiv+MXTiYb0vmQtHj4oonxE= X-Google-Smtp-Source: AGHT+IGH26WtGEtm+ihII6KE5IZJXbaPSgae8apV1KS2tZk1RWRBiY+3m1vgo5C90qe8W2ozL1os+TZiZgjDHOPV35E= X-Received: by 2002:a05:6000:18a9:b0:3e1:da2f:af23 with SMTP id ffacd0b85a97d-3e1da2fb44bmr3340764f8f.9.1757071665906; Fri, 05 Sep 2025 04:27:45 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ashutosh Bapat Date: Fri, 5 Sep 2025 16:57:34 +0530 X-Gm-Features: Ac12FXx6Z8Uxs8y5M3r8NSTJfHfr25fTGQXQcZoOkV8J9pP-p-8Fcd_yp6Ku5HE Message-ID: Subject: Re: [Proposal] Expose internal MultiXact member count function for efficient monitoring To: Naga Appani Cc: 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 Thu, Sep 4, 2025 at 2:41=E2=80=AFAM Naga Appani wrot= e: > > On Fri, Aug 22, 2025 at 6:45=E2=80=AFAM Ashutosh Bapat > wrote: > > > > On Fri, Aug 22, 2025 at 7:37=E2=80=AFAM torikoshia wrote: > > > > Updated docs to include both counts and approximate storage. > This one is remaining. + up to approximately 2^32 entries before reaching wraparound. ... 2^32 entries (occupying roughly 20GB in the pg_multixact/members directory) before reaching wraparound. ... + See for further details on multixact wraparound. I don't think we need this reference here. Reference back from that section is enough. + * Returns NULL if the oldest referenced offset is unknown, which happens during + * system startup or when no MultiXact references exist in any relation. If no MultiXact references exist, and GetMultiXactInfo() returns false, MultiXactMemberFreezeThreshold() will assume the worst, which I take as meaning that it will trigger aggressive autovacuum. No MultiXact references existing is a common case which shouldn't be assumed as the worst case. The comment I quoted means "the oldest value of the offset referenced by any multi-xact referenced by a relation *may not be always known". You seem to have interpreted "may not be known" as "does not exist" That's not right. I would write this as "Returns NULL if the oldest referenced offset is unknown which happens during system startup". Similarly I would rephrase the following docs as + + The function returns NULL when multixact statistics are unavailable. + For example, during startup before multixact initialization completes or = when + the oldest member offset cannot be determined. "The function returns NULL when multixact statistics when the oldest multixact offset corresponding to a multixact referenced by a relation is not known after starting the system." > > > > @@ -0,0 +1,127 @@ > > +# High-signal invariants for pg_get_multixact_stats() What does "High-signal" mean here? Is that term defined somewhere? Using terms that most of the contributors are familiar with improves readability. If a new term is required, it needs to be defined first. But I doubt something here requires defining a new term. > > What's a driver transaction? > A driver transaction is simply the controlling session that stays open > while snapshots are taken. I still don't understand the purpose of this transaction. pg_get_multixact_stats() isn't transactional so the driver transaction isn't holding any "snapshot" of the stats. It's also not creating any multixact and hence does not contribute to testing the output of pg_get_multixact_stats. Whatever this session is doing, can be done outside a transaction too. Which step in this session requires an outer transaction? Some more comments + Returns statistics about current multixact usage: + num_mxids is the number of multixact IDs assigned, Is this the number of multixact IDs assigned till now (since whatever time) or the number of multixact IDs currently in the system? + num_members is the number of multixact member entries created, Similarly this. + multixact allocation and usage patterns in real time. For example: suggestion: ... real time, for example: ... Otherwise the sentence started by "For example" is not a complete sentence. + Returns statistics about current multixact usage: + num_mxids is the number of multixact IDs assigned, Is this the number of multixact IDs assigned till now (since whatever time) or the number of multixact IDs currently in the system? + num_members is the number of multixact member entries created, Similarly this. + multixact allocation and usage patterns in real time. For example: suggestion: ... real time, for example: ... Otherwise the sentence started by "For example" is not a complete sentence. + + values[0] =3D Int32GetDatum(multixacts); This should be UInt32GetDatum() multixacts is uint32. + values[1] =3D Int64GetDatum(members); Similarly this since MultiXactOffset is uint32. + values[4] =3D Int64GetDatum(oldestOffset); Similarly this since MultiXactOffset is uint32. +# Get MultiXact state +{ + oid =3D> '9001', + descr =3D> 'get current multixact member and multixact ID counts and oldest values', suggestion: get current multixact usage statistics. + proname =3D> 'pg_get_multixact_stats', + prorettype =3D> 'record', + proargtypes =3D> '', + proallargtypes =3D> '{int4,int8,int8,xid,int8}', + proargmodes =3D> '{o,o,o,o,o}', + proargnames =3D> '{num_mxids,num_members,members_size,oldest_multixact,oldest_offset}', + provolatile =3D> 'v', + proparallel =3D> 's', + prosrc =3D> 'pg_get_multixact_stats' +}, I like the way you have formatted the new entry, but other entries in this file are not formatted this way. It would be good to format it like other entries but if other reviewers prefer this way, we can go with this too. --=20 Best Wishes, Ashutosh Bapat