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 1muExa-00027M-KH for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Dec 2021 14:27:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1muExZ-0005hk-3K for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Dec 2021 14:27:17 +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 1muExY-0005hb-Oz for pgsql-hackers@lists.postgresql.org; Mon, 06 Dec 2021 14:27:16 +0000 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1muExW-0001rQ-A4 for pgsql-hackers@lists.postgresql.org; Mon, 06 Dec 2021 14:27:16 +0000 Received: by mail-wr1-x42a.google.com with SMTP id a9so22759042wrr.8 for ; Mon, 06 Dec 2021 06:27:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GCVE+7s4SoCHrcgH3XnFah1feAHk7W+YdJuH5d6CWsY=; b=pEBknoRMqG4VkeIp1MPpJ4AsYGuoU5oNQ1oGjRWMEpjpTocVPBJAqQqddMjlpVpOPE mjjZLD4daVNqqD26qfmfrIOOHCHeVj7y/I05xzuFtQBjwISXkpHjioHfty51NM9vMMFM z76CUkhYdyxUWDlMCOWfjYSDBQEnbUl0GGtVwA2Ar7znrhhuvi1CgUdH8+sSTcebf6sI VJLunwo9zi4u/DLngCVkyeye7ftWNgcqkb1daYQSEh1KkQOw1+Fhs9uqdoGSsabouQS3 b1BtAbddl+D1zKdsMEgF3+UK7ydk2l3f+zxcjFuGUpbzczHLu0R+K01rOa69Kas95T3e HjLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GCVE+7s4SoCHrcgH3XnFah1feAHk7W+YdJuH5d6CWsY=; b=4z+sZpYR3QzTY7CI72MrnowLcpxMRasFfQ3IK1BdPC3K4fuqSi5aZsnDVJ7AIo67zH VfOkdFlZd170U+nDxQcvLfXqAgluvP/1rtrIm/QlCnaDkG+uXEzEWHD18B2Z5iOC+9Zp zB//KfbsTgqujw8SNgtwKyWX49AFthKwSqOneqpAw8qbJNNQlw0rRIwQmv/nuumvPfTH g3ZXd01D34U483cS8xrwiVMtOlrvVsac4stJ3c2Wq7Rte9IG2QeHWfQsjI2kE7SK5PEK W1uVLoQrUYPcI9OQx5OTe4ltnNnL5NC5u90K6gVONYGmpkSHv2jSeecQ9JJ3it0ve/// Ui7g== X-Gm-Message-State: AOAM531Y/JkNZbqEFuOpgNY5Uq7BBRBI4oi3PkkhO2N3v7VyDZl8PysV Zv+MmiFemZfw+9nP/xiVu6IxbfCfOpf1KbL9uQw= X-Google-Smtp-Source: ABdhPJypQhzIuC2RutFGjyFztDKzeTFVGwgvBu3739XFphC3CPGjYKrbEmf9D8hCbZuZI5y9yfI/beYQmFdfsooVVo0= X-Received: by 2002:adf:d225:: with SMTP id k5mr44081612wrh.612.1638800832844; Mon, 06 Dec 2021 06:27:12 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: vignesh C Date: Mon, 6 Dec 2021 19:57:01 +0530 Message-ID: Subject: Re: Failed transaction statistics to measure the logical replication progress To: "osumi.takamichi@fujitsu.com" Cc: Masahiko Sawada , Amit Kapila , Greg Nancarrow , "houzj.fnst@fujitsu.com" , "pgsql-hackers@lists.postgresql.org" Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, Dec 4, 2021 at 6:32 PM osumi.takamichi@fujitsu.com wrote: > > On Friday, December 3, 2021 3:12 PM vignesh C wrote: > > Thanks for the updated patch. > > Currently we are storing the commit count, error_count and abort_count for > > each table of the table sync operation. If we have thousands of tables, we will > > be storing the information for each of the tables. > > Shouldn't we be storing the consolidated information in this case. > > diff --git a/src/backend/replication/logical/tablesync.c > > b/src/backend/replication/logical/tablesync.c > > index f07983a..02e9486 100644 > > --- a/src/backend/replication/logical/tablesync.c > > +++ b/src/backend/replication/logical/tablesync.c > > @@ -1149,6 +1149,11 @@ copy_table_done: > > MyLogicalRepWorker->relstate_lsn = *origin_startpos; > > SpinLockRelease(&MyLogicalRepWorker->relmutex); > > > > + /* Report the success of table sync. */ > > + pgstat_report_subworker_xact_end(MyLogicalRepWorker->subid, > > + > > MyLogicalRepWorker->relid, > > + > > 0 /* no logical message type */ ); > Okay. > > I united all stats into that of apply worker. > In line with this change, I fixed the TAP tests as well > to cover the updates of stats done by table sync workers. > > Also, during my self-review, I noticed that > I should call pgstat_report_subworker_xact_end() before > process_syncing_tables() because it can lead to process > exit, which results in missing one increment of the stats columns. > I noted this point in a comment as well. Thanks for the updated patch, few comments: 1) We can keep the documentation similar to mention the count includes both table sync worker / main apply worker in case of commit_count/error_count and abort_count to keep it consistent. + commit_count bigint + + + Number of transactions successfully applied in this subscription. + COMMIT and COMMIT PREPARED increments this counter. + + + + + + error_count bigint + + + Number of transactions that failed to be applied by the table + sync worker or main apply worker in this subscription. + + + + + + abort_count bigint + + + Number of transactions aborted in this subscription. + ROLLBACK PREPARED increments this counter. + + 2) Can this be changed: + /* + * If this is a new error reported by table sync worker, consolidate this + * error count into the entry of apply worker. + */ + if (OidIsValid(msg->m_subrelid)) + { + /* Gain the apply worker stats */ + subwentry = pgstat_get_subworker_entry(dbentry, msg->m_subid, + InvalidOid, true); + subwentry->error_count++; + } + else + subwentry->error_count++; /* increment the apply worker's counter. */ To: + /* + * If this is a new error reported by table sync worker, consolidate this + * error count into the entry of apply worker. + */ + if (OidIsValid(msg->m_subrelid)) + /* Gain the apply worker stats */ + subwentry = pgstat_get_subworker_entry(dbentry, msg->m_subid, + InvalidOid, true); + + subwentry->error_count++; /* increment the apply worker's counter. */ 3) Since both 026_worker_stats and 027_worker_xact_stats.pl are testing pg_stat_subscription_workers, can we move the tests to 026_worker_stats.pl. If possible the error_count validation can be combined with the existing tests. diff --git a/src/test/subscription/t/027_worker_xact_stats.pl b/src/test/subscription/t/027_worker_xact_stats.pl new file mode 100644 index 0000000..31dbea1 --- /dev/null +++ b/src/test/subscription/t/027_worker_xact_stats.pl @@ -0,0 +1,162 @@ + +# Copyright (c) 2021, PostgreSQL Global Development Group + +# Tests for subscription worker statistics during apply. +use strict; +use warnings; +use PostgreSQL::Test::Cluster; +use PostgreSQL::Test::Utils; +use Test::More tests => 1; + +# Create publisher node Regards, Vignesh