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 1jlvgf-0001Oc-Kh for pgsql-general@arkaria.postgresql.org; Thu, 18 Jun 2020 14:38:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jlvgd-0002ui-Vs for pgsql-general@arkaria.postgresql.org; Thu, 18 Jun 2020 14:38:39 +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 1jlvgd-0002ub-Kc for pgsql-general@lists.postgresql.org; Thu, 18 Jun 2020 14:38:39 +0000 Received: from mail-ed1-x543.google.com ([2a00:1450:4864:20::543]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jlvgW-0008I4-Om for pgsql-general@postgresql.org; Thu, 18 Jun 2020 14:38:39 +0000 Received: by mail-ed1-x543.google.com with SMTP id d15so5028117edm.10 for ; Thu, 18 Jun 2020 07:38:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=sqKDn/hi8CZACu3ra2iovca0bEhrD93THOUFEPllsrY=; b=k3S7S1Z2++5yWntaOI2IQdvGT5apYoZII1G9AjFPp8qN/FQfF1aHcuKuLsCHCZBgFs RBHOeRUeGI9PgxFlknkDb5ID/8wHzQY2LEAeiYHpr2SBvFZ138dFw5H/0KLsxRjCa6Xf GtS99K+RUq6jyIGKIFs6draXIDQZYW3/UifHP4IXwDzcegy5SMvC33Z41Syshi8nOjm8 5C+IN0MH17LMnrCBiM+Gg2PEp+BlGdSi60v6PEpabNaWLxNXuTtXIXdnnFFub28qOZEl OnK47bvyiWy6+BG3QmouSxYG78jf6dGlMvS95ZqIA5uxWkzoUvjEYbGDh0d7m4ydIjcI r+mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=sqKDn/hi8CZACu3ra2iovca0bEhrD93THOUFEPllsrY=; b=nh3//y9HbzaXui9OjMFi7Cj4aqOVZkXgbFUxMbLeFU78AVdw3IULeEnfkRpoJzwNs6 s5slk3lr02yGYRzusM5nXKgOz9SbVS/nv4NaYUAe0FPyCob0fTUrCSJeoFoUZMwMge75 /EqkJ8K1ynGM1FhTRSmTQf3uVVgT+U/OwM4j0i+AM2oqT3JksDgMPjbgE/hozVhWKvFG L020a1ZJZUN9xGzrvGSxwOEgbHkDQgQ8Qf9Xd4srMerUNmTvfxWnZ7pObIU78+UXZqNA /L/ktx3Cqqg0akzJYMvHW0308KVyec0K/2Jt95pN1HEn+lAHKrXCgzDeXhMEesOj7lE6 brTg== X-Gm-Message-State: AOAM530UpuxvYUsYrxCoUAA5BrbSzt8qaNokpSttagSp3M80p4JfF+LH CLXYUuZNHmyiZxlg9tQvqo+TvA== X-Google-Smtp-Source: ABdhPJx1OlG//rSHjT47ki1Cu9yUiAskpwuIXQVR/YXPUJYWV0fr1DuGPdcZEiG9kjAuJGG1A8RCFw== X-Received: by 2002:a50:a721:: with SMTP id h30mr4398165edc.153.1592491111729; Thu, 18 Jun 2020 07:38:31 -0700 (PDT) Received: from dynamic-em32qc3bam80l1w4o-pd01.res.v6.highway.a1.net (dynamic-em32qc3bam80l1w4o-pd01.res.v6.highway.a1.net. [2001:871:60:3448:8fa:a39f:2073:8de8]) by smtp.gmail.com with ESMTPSA id h16sm2476784ejq.62.2020.06.18.07.38.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2020 07:38:30 -0700 (PDT) Message-ID: <2d05bf2ad62fc71a5df3d9ba4e75fa300e3e020c.camel@cybertec.at> Subject: Re: Conflict with recovery on PG version 11.6 From: Laurenz Albe To: Toomas Kristin Cc: pgsql-general Date: Thu, 18 Jun 2020 16:38:30 +0200 In-Reply-To: <918BFA04-B89D-4F29-9868-0A113AD72F52@gmail.com> References: <5726DC60-FA11-494F-AC0C-D418DDCC895F@gmail.com> <70b0df32cce4bcb0e5909854e270458714e187f2.camel@cybertec.at> <918BFA04-B89D-4F29-9868-0A113AD72F52@gmail.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.5 (3.32.5-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Toomas Kristin wrote: > > > Basically after upgrade to version 11.5 from 10.6 I experience error messages on streaming > > > replica host “FATAL: terminating connection due to conflict with recovery” and > > > “ERROR: canceling statement due to conflict with recovery”. 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. > > > > > > Is there any changes on version 11.5 what may cause it? > > > > > > Is there any good solution without setting max_standby_streaming_delay=-1 or enabling hot_standby_feedback? > > > > The basic behavior shouldn't have changed since v10. > > > > Check "pg_stat_database_conflicts" to see what kinds of conflicts that are. > > > > The only solutions to avoid queries being canceled due to replication conflicts are: > > > > 1. avoid that such conflicts happen: > > - set "hot_standby_feedback = 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 > > > > 2. set "max_standby_streaming_delay" to -1 > > > > 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. > > 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? There can be other reasons: - replicated ACCESS EXCLUSIVE locks that conflict with queries - replicated ACCESS EXCLUSIVE locks that cause deadlocks - buffer pins that are needed for replication but held by a query - dropped tablespaces that hold temporary files on the standby > 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. That won't help, it will just get your primary bloated. I told you the remedies above, why don't you like them? Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com