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 1jlofd-0002Vj-5b for pgsql-general@arkaria.postgresql.org; Thu, 18 Jun 2020 07:09:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jlofb-0001Ai-UR for pgsql-general@arkaria.postgresql.org; Thu, 18 Jun 2020 07:09:07 +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 1jlofb-0001Ab-MR for pgsql-general@lists.postgresql.org; Thu, 18 Jun 2020 07:09:07 +0000 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jlofY-0003FO-C1 for pgsql-general@postgresql.org; Thu, 18 Jun 2020 07:09:06 +0000 Received: by mail-lj1-x244.google.com with SMTP id x18so5945892lji.1 for ; Thu, 18 Jun 2020 00:09:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:content-transfer-encoding:mime-version:subject:date:references :to:in-reply-to:message-id; bh=NZxGtITP100EtIlGYVi6aWk1QzIb+2uANiSA5m/MEYY=; b=OX/OoskQVRaYFLX/i4T0T7chiuaP2t2SQKpLl8eZHWRHXgvWFnCJmE+7DJ5NWSsxVs wU/qXpRQ0Q362+Pgkp+uS/ovRmbf0h/hPuqYxlONCNrMSxgD6fYXNlKmzhlbNXIL1v+o MyurZpVBjfF1ogK+dgrJjfG0X38xOXO481lTtdvUtnBKxjZUhLU0C0Ns1fD01PHdFyrV I9yJ5HYdDVhuxNXJWKypZ8+Hj1I3BuZJ4UyTtSMOy5/+49aubGEMh26eZKo1l/Iz1EAl tDEZNq2cMHmbqPrnSpJlx2x2TSsQ1/9moq8jCz6lguKBBQ+BdesDltuNqWHrd6sw/2HI oEIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:date:references:to:in-reply-to:message-id; bh=NZxGtITP100EtIlGYVi6aWk1QzIb+2uANiSA5m/MEYY=; b=YXhEhUMEKBpVOCyGvAug0bE+/8nftgQEV9BcnLHspKvbE+RW4DR1dv2kW8lWjQr9oJ GHK3GbphKJQLrHqimFhnlmiElsN48L00ZezQ7Loii2ne6ttjgh92AIc1t0L1/UbPN2Pt U53127fyigB031Gk157pVEaBt0skWKTjeGmX3XBKCOdCafxv44cWWK6lJrUL5QYw8xzh klMmuwm1ypfjg8bX9tli9NpRV+8tKKtYr7SgRWVrCXUWKnraCAVwbasAPl6Fq0dF9Mxc 1TqZ/ghO9mCaYeutyFhZOfwXPoOppWkHjpy+8+TOulR9t+8fgGkMRYOkzIqrYSHq22bG k1hA== X-Gm-Message-State: AOAM533LqGvhDV/eC7FZ4qY8myr63nkTDa1lNoGm3/eAmMlH+zfwR00u Alw3y9WHUlQ6g0JoHgXg8UM= X-Google-Smtp-Source: ABdhPJwJejYG3DMZZhNMh8tWWYZ5ztI3a8yUpUlyhK8iaTI6VIJcBJAs/+n1f5uL/AVp1v18sYvimw== X-Received: by 2002:a2e:a0cc:: with SMTP id f12mr1465942ljm.250.1592464142458; Thu, 18 Jun 2020 00:09:02 -0700 (PDT) Received: from [192.168.10.106] (133-225-29-85.dyn.estpak.ee. [85.29.225.133]) by smtp.gmail.com with ESMTPSA id t4sm446311ljc.28.2020.06.18.00.09.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Jun 2020 00:09:01 -0700 (PDT) From: Toomas Kristin Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: Conflict with recovery on PG version 11.6 Date: Thu, 18 Jun 2020 10:09:00 +0300 References: <5726DC60-FA11-494F-AC0C-D418DDCC895F@gmail.com> <70b0df32cce4bcb0e5909854e270458714e187f2.camel@cybertec.at> <918BFA04-B89D-4F29-9868-0A113AD72F52@gmail.com> To: Laurenz Albe , pgsql-general In-Reply-To: <918BFA04-B89D-4F29-9868-0A113AD72F52@gmail.com> Message-Id: <390F36A7-26FB-467F-9718-07E12AA3C962@gmail.com> X-Mailer: Apple Mail (2.3608.80.23.2.2) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi! What is difference between following error messages? ERROR: canceling statement due to conflict with recovery FATAL: terminating connection due to conflict with recovery I tried to correlate process termination on standby and vacuuming on = master. Here is a sample timeline 1) 2020-06-17 22:45:42 - Last vacuuming before session 2) 2020-06-18 01:01:12 - Session was started at standby 3) 2020-06-18 01:27:53 - Session was terminated at standby 4) 2020-06-18 02:59:32 - Next vacuuming Based on that I would say there is no correlation between vacuuming and = process termination. How can I identify where is the conflict that stops replication and = forces to terminate a query on standby host? BR, Toomas > On 17. Jun 2020, at 16:38, Toomas Kristin = wrote: >=20 > Hi Laurenz, >=20 > Thank you! >=20 > What are reasons for conflicts? Based on documentation seems that the = only reason can be that vacuum removed unused tuples that are in use at = standby host and due to that standby host cannot apply modifications = while blocking query either finishes or will be terminated. isnt it? Or = there can be some other reasons? >=20 > I just wondering what would be impact when I increase value for = autovacuum_vacuum_scale_factor in order force vacuuming process postpone = the clean up process. >=20 > BR, > Toomas >=20 >> On 17. Jun 2020, at 12:42, Laurenz Albe = wrote: >>=20 >> On Wed, 2020-06-17 at 08:42 +0300, Toomas Kristin wrote: >>> Basically after upgrade to version 11.5 from 10.6 I experience error = messages on streaming >>> replica host =E2=80=9CFATAL: terminating connection due to conflict = with recovery=E2=80=9D and >>> =E2=80=9CERROR: canceling statement due to conflict with = recovery=E2=80=9D. There is no changes for >>> vacuuming on master nor max_standby_streaming_delay for replica. I = tried to correlate >>> errors with vacuuming process on master but according to logs there = is no link between >>> them. Somehow I have feeling that when query runs longer than value = for parameter >>> max_standby_streaming_delay the query will be terminated regardless = vacuuming process on master. >>>=20 >>> Is there any changes on version 11.5 what may cause it? >>>=20 >>> Is there any good solution without setting = max_standby_streaming_delay=3D-1 or enabling hot_standby_feedback? >>=20 >> The basic behavior shouldn't have changed since v10. >>=20 >> Check "pg_stat_database_conflicts" to see what kinds of conflicts = that are. >>=20 >> The only solutions to avoid queries being canceled due to replication = conflicts are: >>=20 >> 1. avoid that such conflicts happen: >> - set "hot_standby_feedback =3D on" on the standby and/or >> "vacuum_defer_cleanup_age" on the primary to avoid VACUUM = conflicts >> - Don't lock tables in access exclusive mode >>=20 >> 2. set "max_standby_streaming_delay" to -1 >>=20 >> Note that it can be quite hard to completely avoid replication = conflicts. >> Trying to have both no delay in applying changes and no cancelled = queries >> is often not possible without seriously crippling autovacuum. >>=20 >> Yours, >> Laurenz Albe >> --=20 >> Cybertec | https://www.cybertec-postgresql.com >>=20 >=20