Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nLSFa-0007fQ-A9 for pgsql-hackers@arkaria.postgresql.org; Sat, 19 Feb 2022 16:06:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nLSFY-0005qs-U1 for pgsql-hackers@arkaria.postgresql.org; Sat, 19 Feb 2022 16:06:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nLSBc-0000Hu-Bl for pgsql-hackers@lists.postgresql.org; Sat, 19 Feb 2022 16:02:17 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nLSBX-0002a8-9f for pgsql-hackers@postgresql.org; Sat, 19 Feb 2022 16:02:15 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id F3DEB5C005A; Sat, 19 Feb 2022 11:02:07 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sat, 19 Feb 2022 11:02:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm3; bh=aBxuTYCxRyws4akYkEi7KEeGNRleJWQSlm2ut4 C58II=; b=UlVzNcj0qyMk5s0B+d86FXWj0S177YBqCoW5cQVuIdyc8m8dFrFcND bfHXCwmNY92+CjfJ+XUqyeQaA8QerJMNpeVJO+CD/lXYlTtxUCaNaXjhkWYvvdIE DoYA2J7ObLmltc8ySoYp8piZPRot2gjF95XcaY9wgv3u/Lp9rmkhh2TxPud79a45 Ol7QZhYJx9vXfeE9Q3DBOv9jXIDeXmUAoT/hy4DE49wCFJkYUR8NVmEzh3Y95VFd exlyQUhijlRQhTcLUF4/mva/8Ctpjz6uMHgQV+XHwP1s7B8e2dHJI/kjf4hr1Hiv 32BJEIvIOk8STFtj6QYqm0V4XZllYx/g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=aBxuTYCxRyws4akYk Ei7KEeGNRleJWQSlm2ut4C58II=; b=i1JOlqhKyLKemYXU0Eg1UabLFvLI1dm7W fEPlgV1RBmmFlhKgCx/enITjpnPDhCqq5K5utWBnM9snwwJ0iu10SDpn6I3e3xyw /1hdn2Yu3tWqHddAdP0eZl3ItfvDaJoXUQBU/F2dP3PKqlLnSP6/Ox9tScmPcEKx stUed7Ilbtu9o/hW443R0lpdb0vft3uMhuyYrACklgraMrMJ/qioZu9E4+OlUxBz vvH0flzuhT5pqIavnz6N2gNg4ADjL9rgStoCgWXxYVmpUCQwG06u3ty+UaRs/uuz SZW0xX2FPzQPjyhUCwfpyCnf7EVoaBGxRa46BqA66hqJM86gpfKBw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrkedvgdekfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughrvghs ucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrfgrth htvghrnhepteehheeigfdulefhvedvvddtjeehheekleetkeevgeegudeileeiudeugfef tdejnecuffhomhgrihhnpehpohhsthhgrhgvshhqlhdrohhrghenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrnhgurhgvshesrghnrghrrgii vghlrdguvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 19 Feb 2022 11:02:07 -0500 (EST) Date: Sat, 19 Feb 2022 08:02:03 -0800 From: Andres Freund To: Masahiko Sawada Cc: Amit Kapila , "David G. Johnston" , pgsql-hackers Subject: Re: Design of pg_stat_subscription_workers vs pgstats Message-ID: <20220219160203.y5w2ktc2utthn7pe@alap3.anarazel.de> References: <20220215182641.2cejma6tcgeoqyw2@alap3.anarazel.de> <20220218203255.d3evl6qi2n6gxy6b@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2022-02-19 22:38:19 +0900, Masahiko Sawada wrote: > On Sat, Feb 19, 2022 at 5:32 AM Andres Freund wrote: > > On 2022-02-18 17:26:04 +0900, Masahiko Sawada wrote: > > > With this change, pg_stat_subscription_workers will be like: > > > > > > * subid > > > * subname > > > * subrelid > > > * error_count > > > * last_error_timestamp > > > > > This view will be extended by adding transaction statistics proposed > > > on another thread[1]. > > > > I do not agree with these bits. What's the point of these per-relation stats > > at this poitns. You're just duplicating the normal relation pg_stats here. > > > > I really think we just should drop pg_stat_subscription_workers. Even if we > > don't, we definitely should rename it, because it still isn't meaningfully > > about workers. > > The view has stats per subscription worker (i.e., apply worker and > tablesync worker), not per relation. The subrelid is OID of the > relation that the tablesync worker is synchronizing. For the stats of > apply workers, it is null. That's precisely the misuse of the stats subsystem that I'm complaining about here. The whole design of pgstat (as it is today) only makes sense if you can loose a message and it doesn't matter much, because it's just an incremental counter increment that's lost. And to be able properly prune dead pgstat contents the underlying objects stats are kept around either need to be permanent (e.g. stats about WAL) or a record of objects needs to exist (e.g. stats about relations). Even leaving everything else aside, a key of (dboid, subid, subrelid), where subrelid can be NULL, but where (dboid, subid) is *not* unique, imo is poor relational design. What is the justification for mixing relation specific and non-relation specific contents in this view? The patch you referenced [1] should just store the stats in the pg_stat_subscription view, not pg_stat_subscription_workers. It *does* make sense to keep stats about the number of table syncs that failed etc. But that should be a counter in pg_stat_subscription, not a row in pg_stat_subscription_workers. IOW, we should just drop pg_stat_subscription_workers, and add a few counters to pg_stat_subscription. Greetings, Andres Freund [1] https://www.postgresql.org/message-id/TYCPR01MB8373E658CEE48FE05505A120ED529%40TYCPR01MB8373.jpnprd01.prod.outlook.com