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 1lK34h-0002o0-E0 for pgsql-general@arkaria.postgresql.org; Wed, 10 Mar 2021 17:56:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lK34g-0007WP-8Q for pgsql-general@arkaria.postgresql.org; Wed, 10 Mar 2021 17:56:46 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lK34f-0007WH-QX for pgsql-general@lists.postgresql.org; Wed, 10 Mar 2021 17:56:46 +0000 Received: from mail-qv1-xf30.google.com ([2607:f8b0:4864:20::f30]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lK34c-0005LC-4U for pgsql-general@lists.postgresql.org; Wed, 10 Mar 2021 17:56:44 +0000 Received: by mail-qv1-xf30.google.com with SMTP id a14so1209965qvj.7 for ; Wed, 10 Mar 2021 09:56:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=KUdthrQqQnforuI5FYB14IZt7oocrbmeV2/qRzT1uvo=; b=BlZqiNVO4y4X+ZWSa5YhBL+40kv7gDu77GYgyOU7gkDzypIVRKel9XZn6bMlR+jleG gp67ET2Y1AOc7S6aN+f+6V8h4LuQmQJv0sygo658t7hqNE+5AgLhy+VqeOAj1sRXqVOa GVT1oS4U6SHiACpO64HVv7H6JmnEpNhIEQzDsBURnnQHFRPFSukjoPnqvjaB8t9IqzTM 0QWkeGGIXPgjkWAxfT9Jg47YGOn0o1LTxRtb6maDsQfi/OxYzikFFttpgmJjCx1vZfqU nNIQJO4/hRkbartezR3YmYKpp201r/QG2s+BNO2Mf6NzXhjrIX+qLl7c0DpIpTfPbJAr IGtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=KUdthrQqQnforuI5FYB14IZt7oocrbmeV2/qRzT1uvo=; b=GNgMX587ijPb3GwIKtf4YruacHamd5Xo3E1f0gQMlTrChi5jlDTeNMeipsDX6C6ECk MS99ASjcJtFTvAbbOqqROYLpi8nWi6m4UF+wgoqtCV9mbJUoUekrpmTTyRbyL1Ki7LiG O78wU/shbxh/OdTHFbavjqWUlQm+p3MS49Y4RLvAdCyUnM8LyScpDujw0b3OFXjhwl9N pl6fHKEO8PN+OQTbhB4PGVzq42ovcgPes/6eTnDpCXLPmLrYWMUnOr18MIdO76Bfw+Pg RQAhh2S8TPr2VtsUJom/9WUIikrs3mp5yIbbFNL8di3oI81qNNgY7FT2dhMpNtxFNdMk nVaQ== X-Gm-Message-State: AOAM533ZxqRGm52tY1rW91hHvmQ/x94jems/u2YILGW02ewG9+n/AENc Yjpbf2vKvFLnyJitCzu9ayo= X-Google-Smtp-Source: ABdhPJz6j9jVmYSG4GeqPmRMWCzEyahGJPw5eZyzvVqRbCK2h30tyPImQJHiCW1dX+JAgql76o0wNQ== X-Received: by 2002:a0c:fc06:: with SMTP id z6mr4070688qvo.25.1615399001049; Wed, 10 Mar 2021 09:56:41 -0800 (PST) Received: from [192.168.86.53] (r190-135-252-71.dialup.adsl.anteldata.net.uy. [190.135.252.71]) by smtp.gmail.com with ESMTPSA id d2sm8828qkk.42.2021.03.10.09.56.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Mar 2021 09:56:40 -0800 (PST) From: =?utf-8?B?TWFydMOtbiBGZXJuw6FuZGV6?= Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_D093D6AE-B085-4A63-B67A-9E535389765A" Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) Subject: Re: Logical Replication, CPU load and Locking contention Date: Wed, 10 Mar 2021 14:56:38 -0300 In-Reply-To: <551bab39-627d-a3de-7857-d9161d7c0bc9@gmail.com> Cc: pgsql-general@lists.postgresql.org To: Ron References: <184F3383-E7EC-40FB-8D9B-42E8EBC8D92C@gmail.com> <551bab39-627d-a3de-7857-d9161d7c0bc9@gmail.com> X-Mailer: Apple Mail (2.3654.60.0.2.21) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_D093D6AE-B085-4A63-B67A-9E535389765A Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 10 Mar 2021, at 11:25, Ron wrote: >=20 > On 3/10/21 2:10 AM, Radoslav Nedyalkov wrote: >>=20 >> On Wed, Mar 10, 2021 at 3:56 AM Mart=C3=ADn Fern=C3=A1ndez = > wrote: >> Hello, >>=20 >> I=E2=80=99m troubleshooting a problem at my company with a pg 12 = cluster that we run. >>=20 >> We are using Amazon DMS to replicate data from our database into S3 = buckets. DMS replicates data by using logical replication slots.=20 >>=20 >> After introducing DMS in our environment, we have seen an increase in = CPU load of 20 points at business hours (from ~60% to ~80%). >>=20 >> The other thing that we have identified is that AccessShareLocks = increase considerably when DMS running. >>=20 >> Based on this information, I=E2=80=99m trying to understand if this = is something expected when running logical replication or not. We=E2=80=99= ve been running physical replication for several years and we haven=E2=80=99= t seen nothing like this. It could be the case that the issue is not = related at all with logical replication and is purely a DMS artifact.=20 >>=20 >> Thanks before hand! >>=20 >> Best, >> Mart=C3=ADn >>=20 >>=20 >> Hi, >>=20 >> I would check in pg_stat_activity what those logical replication = slots do. I guess COPY. >=20 > If it's a full-load or full-load-and-cdc, then it's almost certainly a = COPY. We are doing full-load and full-load-and-cdc. At this point it=E2=80=99s = just cdc since the full load was done month ago. >=20 >> Are you doing one shot copy ? every day ? Then copying all the tables = will lead to load increase.=20 >> How many tables at a time DMS copies? It should be configurable. >=20 > It definitely is, with the MaxFullLoadSubTasks parameter. The default = is 8. We are copying a lot of tables. 100+ >=20 >> AccessShareLock is absolutely normal. You have a transaction doing = SELECT (COPY) over a table. >=20 > If DMS with Postgresql as the source is anything like when Oracle is = the source (we're testing Oracle -> RDS Postgresql) then it starts a = SERIALIZABLE transaction. My guess at this point is that the CPU load increases due to the = increase of AccessShareLocks, is that a fair assumption ? Have you seen = a similar behavior in Oracle ? >=20 >> Physical replication is a different thing. It happens at another = level. >>=20 >> Regards >> Rado=20 >=20 > --=20 > Angular momentum makes the world go 'round. --Apple-Mail=_D093D6AE-B085-4A63-B67A-9E535389765A Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On 10 Mar 2021, at 11:25, Ron <ronljohnsonjr@gmail.com> wrote:

=20 =20
On 3/10/21 2:10 AM, Radoslav Nedyalkov wrote:

On Wed, Mar 10, 2021 at = 3:56 AM Mart=C3=ADn Fern=C3=A1ndez <fmartin91@gmail.com> wrote:
Hello,

I=E2=80=99m troubleshooting a problem at my company with a = pg 12 cluster that we run.

We are using Amazon DMS to replicate data from our database into S3 buckets.  DMS replicates data by using logical replication slots.

After introducing DMS in our environment, we have seen an increase in CPU load of 20 points at business hours (from ~60% to ~80%).

The other thing that we have identified is that AccessShareLocks increase considerably when DMS running.

Based on this information, I=E2=80=99m trying to understand = if this is something expected when running logical replication or not. We=E2=80=99ve been running physical replication for = several years and we haven=E2=80=99t seen nothing like this. It = could be the case that the issue is not related at all with logical replication and is purely a DMS artifact.

Thanks before hand!

Best,
Mart=C3=ADn


Hi,

I would check in pg_stat_activity what those = logical replication slots do. I guess COPY.

If it's a full-load or full-load-and-cdc, then it's almost certainly a COPY.

We are doing full-load and full-load-and-cdc. At = this point it=E2=80=99s just cdc since the full load was done month = ago.


Are you doing one shot copy ? every day ? Then = copying all the tables will lead to load increase. 
How many tables at  a time DMS copies? = It should be configurable.

It definitely is, with the MaxFullLoadSubTasks parameter.  The default is 8.

We are copying a lot of tables. 100+


AccessShareLock is absolutely normal. You have = a transaction doing SELECT (COPY) over a table.

If DMS with Postgresql as the source is anything like when Oracle is the source (we're testing Oracle -> RDS Postgresql) then it starts a SERIALIZABLE transaction.

My = guess at this point is that the CPU load increases due to the increase = of AccessShareLocks, is that a fair assumption ? Have you seen a similar = behavior in Oracle ?


Physical replication is a different thing. It = happens at another level.

Regards
Rado 

--
Angular momentum makes the world go 'round.

= --Apple-Mail=_D093D6AE-B085-4A63-B67A-9E535389765A--