On Wed, 18 Sep 2019 at 16:39, Quan Zongliang <
zongliang.q...@postgresdata.com> wrote:

>
> Sybase has a feature to turn off replication at the session level: set
> replication = off, which can be temporarily turned off when there is a
> maintenance action on the table. Our users also want this feature.
> I add a new flag bit in xinfo, control it with a session-level variable,
> when set to true, this flag is written when the transaction is
> committed, and when the logic is decoded it abandons the transaction
> like aborted transactions. Since PostgreSQL has two types of
> replication, I call the variable "logical_replication" to avoid
> confusion and default value is true.
>

There's something related to this already. You can set the replication
origin for the transaction to the special value DoNotReplicateId
(replication origin id 65535). This will suppress replication of the
transaction, at least for output plugins that're aware of replication
origins.

This isn't presently exposed to SQL, it's there for the use of logical
replication extensions. It's possible to expose it with a pretty trivial C
function in an extension.

I think it's a bit of a hack TBH, it's something I perpetrated sometime in
the 9.4 series when we needed a way to suppress replication of individual
transactions. It originated out of core, so the original design was
constrained in how it worked, and maybe it would've actually made more
sense to use an xlinfo flag. Probably not worth changing now though.

Be extremely careful though. If you're hiding things from logical
replication you can get all sorts of confusing and exciting results. I very
strongly suggest you make anything like this superuser-only.

-- 
 Craig Ringer                   http://www.2ndQuadrant.com/
 2ndQuadrant - PostgreSQL Solutions for the Enterprise

Reply via email to