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 1qZKoX-004yrR-A0 for pgsql-hackers@arkaria.postgresql.org; Fri, 25 Aug 2023 00:36:37 +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 1qZKoW-00EZ8c-61 for pgsql-hackers@arkaria.postgresql.org; Fri, 25 Aug 2023 00:36:35 +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 1qZKoV-00EZ8U-Qg for pgsql-hackers@lists.postgresql.org; Fri, 25 Aug 2023 00:36:35 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qZKoS-000sM8-HP for pgsql-hackers@postgresql.org; Fri, 25 Aug 2023 00:36:35 +0000 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-68bec4c6b22so386778b3a.2 for ; Thu, 24 Aug 2023 17:36:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692923790; x=1693528590; 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=EpspkVV+y776K7hmEA4l4xguxSx19le0u5inHZhfSLs=; b=Q+hU9TdwvvSlWJulgcOCCDOVzn12kTuIj8b10icGTZS8qxzpW+oCUds3DOvqHNEHB5 aJnQ7lZaBnRiVEfef5u4hXCsr7kWV+cEG6jYbHFsPISdzKxivSas+fQTKhiinHSOxdhu 1uKeBLNKn3sxadJGema8wfHl8nRZs/T3z1XGnFJGGaFV6JPm+iwB5jlAN+hLsrGtQ/mv /POYB1/X9zL0bQ73HTTZjAew6VYq62iSuWzITBcPga0kZ7U2FdOnwj7ZwiWtCp8SZIV7 ZpmIh091EBZc/9hfkhofNuBmEb/uTsNpOb4uX24gMi5TpnEjPAiEBFPMYu4XPCXqf2Cr NJHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692923790; x=1693528590; 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=EpspkVV+y776K7hmEA4l4xguxSx19le0u5inHZhfSLs=; b=e78H6eUe+PyEcwm368KI+RxkJ4DHevm+HDZ6lg1IOV7m+tAyneHvlM3netL6blFd4+ gX0vMb6T8RrjjUyKG8YX4xu1NKrNh49o2MFX+K5VGS6PHU927cW3iK2e0Lx54APh87I6 90DB2eF1YmVujNDfIltUdS8v9RP7nghsEHQxcOocByGV48sknaGAW6RJVMQPBFdadre8 Ukj8ttZedYViLZ8kZdu3DUcrah9zIZuYabf15Ab8Jn3iNus63MoVFFGFwt9n9Za4//uT svIqx5v3TLBqeiqmQhGFr/ylMPGhnD3RKN6mm/hSe3Uzw5VuiiuvDrjXsWQGscBSJp6j Kz1w== X-Gm-Message-State: AOJu0Yy6wvGQJHJtk1vn0LOES3/SAH7sKfV5OLEA7aysUYX4VZejh09B naokDs74f9m5NwVynLgSpQOsUGqxRrNdnarUP1I= X-Google-Smtp-Source: AGHT+IHOa1LhhN+hy8+pNnjWJP+Szii+5TU7gvpwCFNC2JEiKXiRatwGxyJx4A/izYz+pGwFGJxu5KGOjp4yVpki9Go= X-Received: by 2002:a17:90a:db91:b0:267:f9da:4611 with SMTP id h17-20020a17090adb9100b00267f9da4611mr15659862pjv.14.1692923790224; Thu, 24 Aug 2023 17:36:30 -0700 (PDT) MIME-Version: 1.0 References: <20230824023206.GA1128857@nathanxps13.lan> <20230824025140.GB1128857@nathanxps13.lan> <20230824161913.GA1394441@nathanxps13.lan> In-Reply-To: <20230824161913.GA1394441@nathanxps13.lan> From: Ian Lawrence Barwick Date: Fri, 25 Aug 2023 09:36:18 +0900 Message-ID: Subject: Re: pg_stat_get_backend_subxact() and backend IDs? To: Nathan Bossart Cc: pgsql-hackers , robertmhaas@gmail.com 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 2023=E5=B9=B48=E6=9C=8825=E6=97=A5(=E9=87=91) 1:19 Nathan Bossart : > > On Wed, Aug 23, 2023 at 07:51:40PM -0700, Nathan Bossart wrote: > > On Wed, Aug 23, 2023 at 07:32:06PM -0700, Nathan Bossart wrote: > >> On Thu, Aug 24, 2023 at 10:22:49AM +0900, Ian Lawrence Barwick wrote: > >>> Looking at the code, this is happening because > >>> "pgstat_fetch_stat_local_beentry()" > >>> expects to be passed the backend ID as an integer representing a 1-ba= sed index > >>> referring to "localBackendStatusTable", but "pg_stat_get_backend_subx= act()" > >>> is presumably intended to take the actual BackendId , as per other > >>> "pg_stat_get_XXX()" > >>> functions. > >> > >> Yes, this was changed in d7e39d7, but 10ea0f9 seems to have missed the > >> memo. > > > > BTW I'd argue that this is a bug in v16 that we should try to fix befor= e > > GA, so I've added an open item [0]. I assigned it to Robert (CC'd) sin= ce > > he was the committer, but I'm happy to pick it up. > > Since RC1 is fast approaching, I put together a revised patch set. 0001 > renames the existing pgstat_fetch_stat* functions, and 0002 adds > pgstat_get_local_beentry_by_backend_id() and uses it for > pg_stat_get_backend_subxact(). Thoughts? Thanks for looking at this. In summary we now have these functions: extern PgBackendStatus *pgstat_get_beentry_by_backend_id(BackendId be= id); extern LocalPgBackendStatus *pgstat_get_local_beentry_by_backend_id(BackendId beid); extern LocalPgBackendStatus *pgstat_get_local_beentry_by_index(int beid); which LGTM; patches work as expected and resolve the reported issue. Regards Ian Barwick