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 1lJzmB-00010h-2N for pgsql-general@arkaria.postgresql.org; Wed, 10 Mar 2021 14:25:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lJzmA-0000wH-0u for pgsql-general@arkaria.postgresql.org; Wed, 10 Mar 2021 14:25:26 +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 1lJzm9-0000vy-JK for pgsql-general@lists.postgresql.org; Wed, 10 Mar 2021 14:25:25 +0000 Received: from mail-oo1-xc34.google.com ([2607:f8b0:4864:20::c34]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lJzm7-0003aR-Gi for pgsql-general@lists.postgresql.org; Wed, 10 Mar 2021 14:25:24 +0000 Received: by mail-oo1-xc34.google.com with SMTP id s23so399622oot.12 for ; Wed, 10 Mar 2021 06:25:23 -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=3XpmHXYUBuX6SpRi5+WzB2y8JSrjsMBDQWt9+/Z2iRM=; b=UuwCVsVZZqWd91fDDU8Lgxgp+AyAUcbrpon+Srut9CkFYSM7FBHpofEWp3JxgYbYAx d9zNnTs+11i8uP4fSpiaXUY/96e1uD2AtHUubY8DsbxJz2zTmfBSaNJi73V56y9sV76O XpBetc9i07yaYOnocFh7xYp63i+cyqBDKpqvXEj1B3lWmhH6ukeCcirZyWSxWDA9oI2I kc5lqoqkHaBhMQOy/VDmM4KbI45VDGMdloa+gSMXsryhMWzOTNd8RdlSm2KxaoHlKz04 6cH0mCEhv5CoAg3iI4Bg8HzvHpjCzmzcqILjesB7C1SsT4bLQJHt640jEzzkFqO0qGbu QhHA== 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=3XpmHXYUBuX6SpRi5+WzB2y8JSrjsMBDQWt9+/Z2iRM=; b=sepKaT0AwHTEMB9zVMrkDIqLdyaIpjU50+7TL4yQZLgw4p47xIK3q/qzIOBU2Vks9v Hz4UW0Nr66yNo5PtyN+GSF1Zs4Xgns7ybLRwXCyc+/RZhSct7ne0V0g0l1MAIBeyGmIL GHlq5WxhZ0na7XU0bYJ8Gni5Vj09/I626ZJ4S5H1z3BdoNZKIY8r8DPYz2ZyIM8dAEgc AdFjs9YtxNOHrdqKdYV7TgOYWAepk1ac+YHxwc4RfLH/zzumqMheBRmJXq+UKnwvAAGr n5iqoJRgmxPMf0BLvilW1gIKe3BD06JF0prpnoTA0APXux7hWM/CN9IKtZXib7NiZzLf QEsQ== X-Gm-Message-State: AOAM532+DMqNUx6loaYVrEhkiS2SigQ75kfJKQGIh+z6LwVnXKuc8jL9 Yv5LYnPatDk7fU3cKAPVoRUFIwlrWwk= X-Google-Smtp-Source: ABdhPJzNHvtntz83Dqzqhj7ZIJz26OA0ziXJdTyqHxD555cooZ4R0FJTy9fONhteZKfcZWiYAPpdMw== X-Received: by 2002:a4a:eb8a:: with SMTP id d10mr2448782ooj.32.1615386322557; Wed, 10 Mar 2021 06:25:22 -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 d21sm3739745oic.54.2021.03.10.06.25.21 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 10 Mar 2021 06:25:21 -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> From: Ron Message-ID: <551bab39-627d-a3de-7857-d9161d7c0bc9@gmail.com> Date: Wed, 10 Mar 2021 08:25:21 -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="------------CAF44F706654AA5196CB6ADC" 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. --------------CAF44F706654AA5196CB6ADC Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit 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. > 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. > 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. > Physical replication is a different thing. It happens at another level. > > Regards > Rado -- Angular momentum makes the world go 'round. --------------CAF44F706654AA5196CB6ADC Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit 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.

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.

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.

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

Regards
Rado 

--
Angular momentum makes the world go 'round.
--------------CAF44F706654AA5196CB6ADC--