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 1lK3BX-0003J2-2M for pgsql-general@arkaria.postgresql.org; Wed, 10 Mar 2021 18:03:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lK3BU-0004bF-Od for pgsql-general@arkaria.postgresql.org; Wed, 10 Mar 2021 18:03:48 +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 1lK3BU-0004aJ-8L for pgsql-general@lists.postgresql.org; Wed, 10 Mar 2021 18:03:48 +0000 Received: from mail-oi1-x235.google.com ([2607:f8b0:4864:20::235]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lK3BL-0005Ne-49 for pgsql-general@lists.postgresql.org; Wed, 10 Mar 2021 18:03:47 +0000 Received: by mail-oi1-x235.google.com with SMTP id w65so20060664oie.7 for ; Wed, 10 Mar 2021 10:03:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=E5Xnau4pyQbKPIgsnSOFdR2VVFBdqdp/95JDxR3bT38=; b=H1LCa/sKRk5iTkUolJcHV/EzRaLaD+J/2IpUHTfcXvMw5/EtORsH646en1D18QBOjB j9zGcdoMLe3J6kHmPLqJ1bUB2pG6nzGVfTE4FC42rHfqfmYsLAM+7PgcvdaV7c3dVs4h DEnAqZAWvbJ1AY7cj9uukKwLj/5GNc5Qw+CejV7loQzDj9jenQZuo6mI9gOHql98TDnM 5O2HSuSrcYFoV8+ryXxHbVsOEdikDLyMivt8OYox1GtrylgMD3FA1sOFnhwyWm4D38Zy kCSHv+We81DjNDcEh9mFmU8ojtr7wJ3XMcouutfS1LtsEJYjYjdM5CjCbpzGq6GrP+vG kZdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=E5Xnau4pyQbKPIgsnSOFdR2VVFBdqdp/95JDxR3bT38=; b=HSuxWyEFvJAyOrcLTdvINpcrCy/u7pkJ8t9ItBS16dDaI8ut0OMOyw3Q51s1Zaq+lk ENwvHTCxC6U/D7aTSXiUfe1HOx5Tn2CA1+1zqj0V1ekCAPORo7t9Foq6OO5OzNT53V7k z7jtMXCFj7lsxFcPO/GiAAYJYs1oezHrZ7UzWfWipm09wg3LsMkVgKwmv84cBg5ffGza Zy1m6RUbDJHQvLfAhTFNuYRd6rMatw0XDf/ysbv6fGUqCaPpOJe5vJ0Lh+LdcioHJbhG QpJujW3p7tvgGyMKGVHF5yRHBSZbO/opqUuHzTxKXTgsA7oa8lpvodMUPg4hMak56WZj jRTA== X-Gm-Message-State: AOAM531WCVcPGbhvgTBxveTX6IQuU/kY9HBBWeTodH67NlZK08o1QWm/ 7lBKUybyReDV5S7zquknvyjvhHeDZxQ= X-Google-Smtp-Source: ABdhPJxeeTu5EK6RnaGfBX+rm8Z7Ca1ygjDMii2QphIjyEefEy+3NyV2X5HNAEQfwP1LhvqH0g4Seg== X-Received: by 2002:a05:6808:481:: with SMTP id z1mr3233764oid.165.1615399417858; Wed, 10 Mar 2021 10:03:37 -0800 (PST) Received: from [192.168.88.10] (ip174-67-141-204.no.no.cox.net. [174.67.141.204]) by smtp.googlemail.com with ESMTPSA id x25sm68943oto.72.2021.03.10.10.03.37 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 10 Mar 2021 10:03:37 -0800 (PST) Subject: Re: Logical Replication, CPU load and Locking contention To: pgsql-general@lists.postgresql.org References: <184F3383-E7EC-40FB-8D9B-42E8EBC8D92C@gmail.com> <551bab39-627d-a3de-7857-d9161d7c0bc9@gmail.com> From: Ron Message-ID: <591d633a-332b-a47a-fb4c-a58a72566f7c@gmail.com> Date: Wed, 10 Mar 2021 12:03:36 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------B27A74DC27784409E0164403" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------B27A74DC27784409E0164403 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 3/10/21 11:56 AM, Martín Fernández wrote: > > >> On 10 Mar 2021, at 11:25, Ron > > wrote: >> >> On 3/10/21 2:10 AM, Radoslav Nedyalkov wrote: >>> >>> On Wed, Mar 10, 2021 at 3:56 AM Martín Fernández >> > wrote: >>> >>> Hello, >>> >>> I’m 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’m trying to understand if this is >>> something expected when running logical replication or not. We’ve >>> been running physical replication for several years and we haven’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. >>> >>> Thanks before hand! >>> >>> Best, >>> Martín >>> >>> >>> 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’s just cdc > since the full load was done month ago. Then it's "just" logical replication. >> >>> 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 *synchronizing* lots of tables.  How often are they modified? >> >>> 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. --------------B27A74DC27784409E0164403 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit On 3/10/21 11:56 AM, Martín Fernández 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ín Fernández <fmartin91@gmail.com> wrote:
Hello,

I’m 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’m trying to understand if this is something expected when running logical replication or not. We’ve been running physical replication for several years and we haven’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.

Thanks before hand!

Best,
Martín


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’s just cdc since the full load was done month ago.

Then it's "just" logical replication.


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 synchronizing lots of tables.  How often are they modified?


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.
--------------B27A74DC27784409E0164403--