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 1nCFNG-000514-NC for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Jan 2022 06:32:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nCFMj-0004yM-OF for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Jan 2022 06:31:41 +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 1nCFMi-0004yD-Lo for pgsql-hackers@lists.postgresql.org; Tue, 25 Jan 2022 06:31:41 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nCFMf-0000d8-7l for pgsql-hackers@postgresql.org; Tue, 25 Jan 2022 06:31:40 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 9CF263201E00; Tue, 25 Jan 2022 01:31:34 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Tue, 25 Jan 2022 01:31:34 -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:message-id :mime-version:reply-to:sender:subject:subject:to:to; s=fm3; bh=D 0cdOr4/73OMbn694ps9GIOBJJtYJPLJ9ZOEBMYN5r4=; b=w0rRL4n/Ie/E5GR89 RSCvyiS7nEzBQ3CJFdW1LU9/K1wXUgk7x8Y6N73mg0voao44gSc/2k7iV+z3oMoG JHRXc7FjBS2ltqiB92BIEYfM8b2JbMICxrmWjJDURVgL2K5Bkuh2i3/UbaZ8o5lk n31puikgsDpsfe3i66dr+EC0SpZK/0o84W7eDM8bRPgiSmUOtJaqV1jmdubngH0W app4Gb8UcxK2uXv+FKBGPHcia0I2dXnMdf0caF60egJYH/se2uEIoYr1KQnrfaUx c/0AbIWebo3OwTAJTq2SX+YVeGFP005WcY1fk4VCHjmrY6v5gyZ0gzCWOIxMBJ0d RiqMg== 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:message-id:mime-version:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=D0cdOr4/73OMbn694ps9GIOBJJtYJPLJ9ZOEBMYN5 r4=; b=UyHrwcW2iFGuuu7FgDjzDhmXeyoVfsDSANS5ciWcBpSL3ncRassZktsl7 VllZK4GiTROYJrVGrLrLnP8HpgQIgBuoDinj1PG6hlsWo4aFX6labxKda26xJxpo SGPU3xM26MT3E+ae06Hfa4wLtGvyEkzCgH99JNW2N6GYl8TJACoF0SmWsPTo4FGl Q6O5ZwswehKOqLsctcJpCuMTvYh3VLrY8oVNCC4QR+98A+J14ci06jeJkMJMNvzk GjULHoINOHqgNSv5SchJrzjpyIJs2tT+a3IwQrWnvznRAJyJq65D/uoID48w0Cbe ReAmT1H+pvcnQVMPlnPuxB8Gurshg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrvdekgdeliecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkgggtugesthdtredttddtvdenucfhrhhomheptehnughrvghsucfh rhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrfgrthhtvg hrnhepfeehfeehffdthfehleelteeviefggeeiieeiheffjeevleegkefgtdeitdetffei necuffhomhgrihhnpehpohhsthhgrhdrvghspdhpohhsthhgrhgvshhqlhdrohhrghenuc evlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrnhgurhgv shesrghnrghrrgiivghlrdguvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 25 Jan 2022 01:31:32 -0500 (EST) Date: Mon, 24 Jan 2022 22:31:31 -0800 From: Andres Freund To: pgsql-hackers@postgresql.org Cc: Masahiko Sawada , Amit Kapila Subject: Design of pg_stat_subscription_workers vs pgstats Message-ID: <20220125063131.4cmvsxbz2tdg6g65@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, I was looking the shared memory stats patch again. The rebase of which collided fairly heavily with the addition of pg_stat_subscription_workers. I'm concerned about the design of pg_stat_subscription_workers. The view was introduced in commit 8d74fc96db5fd547e077bf9bf4c3b67f821d71cd Author: Amit Kapila Date: 2021-11-30 08:54:30 +0530 Add a view to show the stats of subscription workers. This commit adds a new system view pg_stat_subscription_workers, that shows information about any errors which occur during the application of logical replication changes as well as during performing initial table synchronization. The subscription statistics entries are removed when the corresponding subscription is removed. It also adds an SQL function pg_stat_reset_subscription_worker() to reset single subscription errors. The contents of this view can be used by an upcoming patch that skips the particular transaction that conflicts with the existing data on the subscriber. This view can be extended in the future to track other xact related statistics like the number of xacts committed/aborted for subscription workers. Author: Masahiko Sawada Reviewed-by: Greg Nancarrow, Hou Zhijie, Tang Haiying, Vignesh C, Dilip Kumar, Takamichi Osumi, Amit Kapila Discussion: https://postgr.es/m/CAD21AoDeScrsHhLyEPYqN3sydg6PxAPVBboK=30xJfUVihNZDA@mail.gmail.com I tried to skim-read the discussion leading to its introduction, but it's extraordinarily long: 474 messages in [1], 131 messages in [2], as well as a few other associated threads. From the commit message alone I am concerned that this appears to be intended to be used to store important state in pgstats. For which pgstats is fundamentally unsuitable (pgstat can loose state during normal operation, always looses state during crash restarts, the state can be reset). I don't really understand the name "pg_stat_subscription_workers" - what workers are stats kept about exactly? The columns don't obviously refer to a single worker or such? From the contents it should be name pg_stat_subscription_table_stats or such. But no, that'd not quite right, because apply errors are stored per-susbcription, while initial sync stuff is per-(subscription, table). The pgstat entries are quite wide (292 bytes), because of the error message stored. That's nearly twice the size of PgStat_StatTabEntry. And as far as I can tell, once there was an error, we'll just keep the stats entry around until the subscription is dropped. And that includes stats for long dropped tables, as far as I can see - except that they're hidden from view, due to a join to pg_subscription_rel. To me this looks like it's using pgstat as an extremely poor IPC mechanism. Why isn't this just storing data in pg_subscription_rel? Greetings, Andres Freund [1] https://www.postgresql.org/message-id/CAD21AoDeScrsHhLyEPYqN3sydg6PxAPVBboK%3D30xJfUVihNZDA%40mail.gmail.com [2] https://postgr.es/m/OSBPR01MB48887CA8F40C8D984A6DC00CED199%40OSBPR01MB4888.jpnprd01.prod.outlook.com