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 1lKLos-00028Y-J6 for pgsql-general@arkaria.postgresql.org; Thu, 11 Mar 2021 13:57:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lKLoq-0007QF-RC for pgsql-general@arkaria.postgresql.org; Thu, 11 Mar 2021 13:57:40 +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 1lKLoq-0007Q8-Cf for pgsql-general@lists.postgresql.org; Thu, 11 Mar 2021 13:57:40 +0000 Received: from mail-qt1-x82c.google.com ([2607:f8b0:4864:20::82c]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lKLok-0005zs-VA for pgsql-general@lists.postgresql.org; Thu, 11 Mar 2021 13:57:39 +0000 Received: by mail-qt1-x82c.google.com with SMTP id l13so1154392qtu.9 for ; Thu, 11 Mar 2021 05:57:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=content-transfer-encoding:mime-version:subject:from:in-reply-to:cc :date:message-id:references:to; bh=Mkgmop/v+qcUAmTrSZaklu5PlBsUYUVnq8eAIRk8D8A=; b=O2fIrnm8DwU30R+QxkSVD4emI+bTBkd14mW2cxAtcaZAdTX4VkjA1rYLF24UlC4Ss+ Ix97n0OY55ZBQwHuqnyUu2J94gbB1V2hbpkyWbHtDBOFu1h5c3PDa8KlZ2M2QYAF8pQ5 O+GpX4DscZA8R38TjGV7QPkMkr3uh61+bNN6UcCMLqOjUbPZ3OlQlv/1LKokHupHjPC4 T9+rib8Q0h7qbd9gzG2ossAnZoEAx3WDqG2GdIQ7CdRyJcVypg7J+AyCKNodVbMi053E oekrvBD0CmbLlKTho4FqjlUd9pRwp1djAK3LSg++VdHOkhcfTXI6FSy7jDSZoqVEk2U2 SgmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:mime-version:subject :from:in-reply-to:cc:date:message-id:references:to; bh=Mkgmop/v+qcUAmTrSZaklu5PlBsUYUVnq8eAIRk8D8A=; b=it/qIdCVuJnt64DaYlwo9fzUAvsfSSxEg3Y8wnTElSIIR7LT5kM+Y6yuUkuKb1MSzP 9SxZDDCKYmMKNsOl2naBbPt+MXhTVpBvNbcqWMBaUFfF2GYQYjzdymD4uEkQI9H7vMKT hJrs/wF6R4jzsnhFcsuVV9orifwi1/dVC0itAtkTvnNUdeokxuoJZoy9JtzQqRZJSqt+ RUuXvP8nhcuJAly9C6WVcmg9UfrN9UQl0Bscn56efA5wnpOSHhM6h5RafKTVewazseTf kyjkzAACoyoafoletWlPa1a6aayZTzrl+xYaCVaoeCV0hFFo5h04A84ERDX15B1iYaiX SA3w== X-Gm-Message-State: AOAM532Pb5Et/GOKKnEyVT4ONKt+9uOrflYcyz/Lu9u4Iv6+HVHXeNhC rXhvIQ7sHuI6YTb5i7p50sW6DsR36fyGAA== X-Google-Smtp-Source: ABdhPJzOvwWIrtjmC6R6ebj5zYUIwa79ZmD2A0qvBKaOPKP/uCqzFnPk3og/G4DGmEz4+rddNaMEaA== X-Received: by 2002:ac8:698c:: with SMTP id o12mr7492046qtq.340.1615471053470; Thu, 11 Mar 2021 05:57:33 -0800 (PST) Received: from [10.0.1.33] (r167-57-206-138.dialup.adsl.anteldata.net.uy. [167.57.206.138]) by smtp.gmail.com with ESMTPSA id c5sm1967899qkg.105.2021.03.11.05.57.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Mar 2021 05:57:32 -0800 (PST) Content-Type: multipart/alternative; boundary=Apple-Mail-AD3BB53D-C17A-42F7-A3D0-0E435D16FD0C Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (1.0) Subject: Re: Logical Replication, CPU load and Locking contention From: fmartin91@gmail.com In-Reply-To: <591d633a-332b-a47a-fb4c-a58a72566f7c@gmail.com> Cc: pgsql-general@lists.postgresql.org Date: Thu, 11 Mar 2021 10:57:31 -0300 Message-Id: <54D96E0A-0BFE-4E2D-A32B-90F05D40315F@gmail.com> References: <591d633a-332b-a47a-fb4c-a58a72566f7c@gmail.com> To: Ron X-Mailer: iPhone Mail (18D52) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail-AD3BB53D-C17A-42F7-A3D0-0E435D16FD0C Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Sent from my iPhone > On Mar 10, 2021, at 15:03, Ron wrote: > =EF=BB=BF On 3/10/21 11:56 AM, Mart=C3=ADn Fern=C3=A1ndez wrote: >>=20 >>=20 >>> 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 clust= er that we run. >>>>>=20 >>>>> We are using Amazon DMS to replicate data from our database into S3 bu= ckets. DMS replicates data by using logical replication slots.=20 >>>>>=20 >>>>> After introducing DMS in our environment, we have seen an increase in C= PU load of 20 points at business hours (from ~60% to ~80%). >>>>>=20 >>>>> The other thing that we have identified is that AccessShareLocks incre= ase 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=99ve b= een running physical replication for several years and we haven=E2=80=99t se= en nothing like this. It could be the case that the issue is not related at a= ll with logical replication and is purely a DMS artifact.=20 >>>>>=20 >>>>> Thanks before hand! >>>>>=20 >>>>> Best, >>>>> Mart=C3=ADn >>>>=20 >>>> Hi, >>>>=20 >>>> I would check in pg_stat_activity what those logical replication slots d= o. I guess COPY. >>>=20 >>> If it's a full-load or full-load-and-cdc, then it's almost certainly a C= OPY. >>=20 >> We are doing full-load and full-load-and-cdc. At this point it=E2=80=99s j= ust cdc since the full load was done month ago. >=20 > Then it's "just" logical replication. Right! >=20 >>>=20 >>>> Are you doing one shot copy ? every day ? Then copying all the tables w= ill 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 i= s 8. >>=20 >> We are copying a lot of tables. 100+ >=20 > If right now you're just doing CDC replication, then you're synchronizing l= ots of tables. How often are they modified? >=20 Yes, used the word copying incorrectly. Last time we paused DMS we acumulate= d 180GB in the replication slot in 1 hour.=20 >>>=20 >>>> AccessShareLock is absolutely normal. You have a transaction doing SELE= CT (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 SERIALIZAB= LE transaction. >>=20 >> 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 be= havior in Oracle ? >=20 > I don't have access to the Oracle database, and so far we're just testing o= n the low-volume QA system. >=20 > Further, I don't know enough about how logical replication works to have a= n opinion. >=20 > --=20 > Angular momentum makes the world go 'round. --Apple-Mail-AD3BB53D-C17A-42F7-A3D0-0E435D16FD0C Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable


S= ent from my iPhone

On Ma= r 10, 2021, at 15:03, Ron <ronljohnsonjr@gmail.com> wrote:

=EF=BB=BF =20 =20 =20 On 3/10/21 11:56 AM, Mart=C3=ADn Fern=C3=A1ndez wrote:


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

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 <fmartin9= 1@gmail.com> wrote:
Hello,

I=E2=80=99m troubleshooting a problem at my company wi= th 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.

Then it's "just" logical replication.

Right!



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+

If right now you're just doing CDC replication, then you're synchroni= zing lots of tables.  How often are they modified?


Yes, used the word copying in= correctly. Last time we paused DMS we acumulated 180GB in the replication sl= ot in 1 hour. 



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 ?

I don't have access to the Oracle database, and so far we're just testing on the low-volume QA system.

Further, I don't know enough about how logical replication works to have an opinion.

--
Angular momentum makes the world go 'round.
=20
= --Apple-Mail-AD3BB53D-C17A-42F7-A3D0-0E435D16FD0C--