pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Toomas Kristin <toomas.kristin@gmail.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: Conflict with recovery on PG version 11.6
Date: Thu, 18 Jun 2020 16:38:30 +0200
Message-ID: <2d05bf2ad62fc71a5df3d9ba4e75fa300e3e020c.camel@cybertec.at> (raw)
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>

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






view thread (12+ messages)  latest in thread

Message-ID: <2d05bf2ad62fc71a5df3d9ba4e75fa300e3e020c.camel@cybertec.at>
Permalink:  ../2d05bf2ad62fc71a5df3d9ba4e75fa300e3e020c.camel@cybertec.at/
Also on:    postgresql.org/message-id/2d05bf2ad62fc71a5df3d9ba4e75fa300e3e020c.camel@cybertec.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: laurenz.albe@cybertec.at, toomas.kristin@gmail.com
  Subject: Re: Conflict with recovery on PG version 11.6
  In-Reply-To: <2d05bf2ad62fc71a5df3d9ba4e75fa300e3e020c.camel@cybertec.at>
  References: <5726DC60-FA11-494F-AC0C-D418DDCC895F@gmail.com> <70b0df32cce4bcb0e5909854e270458714e187f2.camel@cybertec.at> <918BFA04-B89D-4F29-9868-0A113AD72F52@gmail.com> <2d05bf2ad62fc71a5df3d9ba4e75fa300e3e020c.camel@cybertec.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox