pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: pgsql-hackers@postgresql.org
Subject: Assertion failure in pg_copy_logical_replication_slot()
Date: Tue, 23 Jun 2020 00:17:47 +0900
Message-ID: <f91de4fb-a7ab-b90e-8132-74796e049d51@oss.nttdata.com> (raw)

Hi,

If restart_lsn of logical replication slot gets behind more than
max_slot_wal_keep_size from the current LSN, the logical replication
slot would be invalidated and its restart_lsn is reset to an invalid LSN.
If this logical replication slot with an invalid restart_lsn is specified
as the source slot in pg_copy_logical_replication_slot(), the function
causes the following assertion failure.

     TRAP: FailedAssertion("!logical_slot", File: "slotfuncs.c", Line: 727)

This assertion failure is caused by

	/* Copying non-reserved slot doesn't make sense */
	if (XLogRecPtrIsInvalid(src_restart_lsn))
		ereport(ERROR,
				(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
				 errmsg("cannot copy a replication slot that doesn't reserve WAL")));

I *guess* this assertion check was added because restart_lsn should
not be invalid before. But in v13, it can be invalid thanks to max_slot_wal_keep_size.
I think that this assertion check seems useless and should be removed in v13.
Patch attached. Thought?

Regards,

-- 
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

Attachments:

fix_assertion_in_pg_copy_logical_replication_slot.patch (text/plain, 640B) download diff --git a/src/backend/replication/slotfuncs.c b/src/backend/replication/slotfuncs.c index 06e4955de7..bc3fcbff4d 100644 --- a/src/backend/replication/slotfuncs.c +++ b/src/backend/replication/slotfuncs.c @@ -723,12 +723,9 @@ copy_replication_slot(FunctionCallInfo fcinfo, bool logical_slot) /* Copying non-reserved slot doesn't make sense */ if (XLogRecPtrIsInvalid(src_restart_lsn)) - { - Assert(!logical_slot); ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot copy a replication slot that doesn't reserve WAL"))); - } /* Overwrite params from optional arguments */ if (PG_NARGS() >= 3)

view thread (7+ messages)  latest in thread

Message-ID: <f91de4fb-a7ab-b90e-8132-74796e049d51@oss.nttdata.com>
Permalink:  ../f91de4fb-a7ab-b90e-8132-74796e049d51@oss.nttdata.com/
Also on:    postgresql.org/message-id/f91de4fb-a7ab-b90e-8132-74796e049d51@oss.nttdata.com

 ·  · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: masao.fujii@oss.nttdata.com
  Subject: Re: Assertion failure in pg_copy_logical_replication_slot()
  In-Reply-To: <f91de4fb-a7ab-b90e-8132-74796e049d51@oss.nttdata.com>

* 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