Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hVG6q-00037r-Si for pgsql-hackers@arkaria.postgresql.org; Mon, 27 May 2019 13:56:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hVG6n-00066J-W0 for pgsql-hackers@arkaria.postgresql.org; Mon, 27 May 2019 13:56:13 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hVG6n-0005tf-Ip for pgsql-hackers@lists.postgresql.org; Mon, 27 May 2019 13:56:13 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hVG6g-0007qE-DY for pgsql-hackers@postgresql.org; Mon, 27 May 2019 13:56:11 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id AF469331; Mon, 27 May 2019 09:56:04 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Mon, 27 May 2019 09:56:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=G4xCWrfkyTcxyp1sgwXqPM2vSe6 LB3hh0YnjUyAgcf4=; b=kk7bJ2yBIL1exuQB5r3ijdkLvp3VnVX0gOK0z6rxAa5 4HlfU/55KwqY5PaninZkpPwZoKTlkTQg1ZHB5Ttl+/gb+iyjTOegCH2k+5tgKkSL 7/QtkqDmjTrQiSus/8bLyK8sWP2QNBmITqApvkmSwSuggXxqkMosxytDJH2VSPMb 73DPEFlzM7/iTKgmax61g/M2UxHJlHRVgiNJy/hTZqhKAlOD5eJFnRmRhzhgJp0I /CJsVM/ZLQdx5URmngNvvkfa/lKAAvuSrtpC27joqTt4xh6f3EfvYDVz0hsHI+ep ZYu6z2Jbe/ZLhzkLzXcfmITQpwHbTYqzqRlxbJHhZLQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=G4xCWr fkyTcxyp1sgwXqPM2vSe6LB3hh0YnjUyAgcf4=; b=fojP3LYqIf0zM7+EK48uDF tiwrRu4oGpdArpTB56bIDGAG9koD1aEK7xtiV2by3KO/dutePyQ9otB8DjYjVdOq GX2dHsEf7H3h/EOXoPkNBdI+wqt+fYoM8NCIqIUrh6avrpVfSZk3OSA/KsJhaK+E ARbbVreP4+ZJNOeSvuqdtO6pr9h6TxiPbPS8T+IvZxFR0nq5wXc+VIsTptvO3ifI 66rvpdCFuPW1c2T9exWKoslLmSDsusGNAbvurFGEMiqPDbEgJNWdI4UL+xvf+y3H +Fo+hjuagfHWBa3rpn+hZCCXc6778XeZgyP1qBHIpayC/cYdtq545x2RozwUcnUQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddruddvvddgjedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeetnhgurhgv shcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucfkphepud ejvddrheekrddvtddurdelnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrnhgurhgvshes rghnrghrrgiivghlrdguvgenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from intern.anarazel.de (unknown [172.58.201.9]) by mail.messagingengine.com (Postfix) with ESMTPA id 7F9F380064; Mon, 27 May 2019 09:56:03 -0400 (EDT) Date: Mon, 27 May 2019 06:56:02 -0700 From: Andres Freund To: Amit Khandekar Cc: tushar , Petr Jelinek , Robert Haas , Craig Ringer , Petr Jelinek , pgsql-hackers Subject: Re: Minimal logical decoding on standbys Message-ID: <20190527135602.dw6cp5vttbdb76i7@alap3.anarazel.de> References: <20190412192747.m73h2qnddrpzefij@alap3.anarazel.de> <20190521161937.tpepqkiatw6kv35v@alap3.anarazel.de> <20190523155901.acm4umrl6adrcwt4@alap3.anarazel.de> <20190523174821.s3kgumgmo35opavg@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2019-05-27 17:04:44 +0530, Amit Khandekar wrote: > On Fri, 24 May 2019 at 21:00, Amit Khandekar wrote: > > > > On Fri, 24 May 2019 at 19:26, Amit Khandekar wrote: > > > Working on the patch now .... > > > > Attached is an incremental WIP patch > > handle_wal_level_changes_WIP.patch to be applied over the earlier main > > patch logical-decoding-on-standby_v4_rebased.patch. > > I found an issue with these changes : When we change master wal_level > from logical to hot_standby, and again back to logical, and then > create a logical replication slot on slave, it gets created; but when > I do pg_logical_slot_get_changes() with that slot, it seems to read > records *before* I created the logical slot, so it encounters > parameter-change(logical=>hot_standby) record, so returns an error as > per the patch, because now in DecodeXLogOp() I error out when > XLOG_PARAMETER_CHANGE is found : > @@ -190,11 +190,23 @@ DecodeXLogOp(LogicalDecodingContext *ctx, > XLogRecordBuffer *buf) > * can restart from there. > */ > break; > + case XLOG_PARAMETER_CHANGE: > + { > + xl_parameter_change *xlrec = > + (xl_parameter_change *) XLogRecGetData(buf->record); > + > + /* Cannot proceed if master itself does not have logical data */ > + if (xlrec->wal_level < WAL_LEVEL_LOGICAL) > + ereport(ERROR, > + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), > + errmsg("logical decoding on standby requires " > + "wal_level >= logical on master"))); > + break; > + } > > I thought it won't read records *before* the slot was created. Am I > missing something ? That's why I had mentioned that you'd need to adapt ReplicationSlotReserveWal(), to use the replay LSN or such. Greetings, Andres Freund