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 1jTT7J-0003AH-MC for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Apr 2020 16:29:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jTT7I-0004JP-Id for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Apr 2020 16:29:52 +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 1jTT7I-0004JH-8M for pgsql-hackers@lists.postgresql.org; Tue, 28 Apr 2020 16:29:52 +0000 Received: from mail-qk1-x741.google.com ([2607:f8b0:4864:20::741]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jTT7E-0003mk-8X for pgsql-hackers@lists.postgresql.org; Tue, 28 Apr 2020 16:29:51 +0000 Received: by mail-qk1-x741.google.com with SMTP id o19so22413264qkk.5 for ; Tue, 28 Apr 2020 09:29:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=/5wZNJtp2mX8NfBRTYQuZh4HmOw71AFLZUW10N+aBsQ=; b=j4lSMXeFx56f/t5qMDmmvkIMaKV2yo/xNYsqzrEYbmunkGTHx3hP8ZxXyKEjbySfj3 vY9zeHGnbKRBd9Ol8AGjTsM2YmTeiq0NdvYn9W53yawI66HEIud7hJ5nss/X1xk4HNLY S+W5brY8CpbnC0QRiaQuyEJqa7e3AJUiuZ+eANfWshqW/vbX+f/LF854W/oxMDjhwZLA ALkp7pxsRCmtxEczGNXNaefYpCBq9fg7Q6xLLn/r/sU92LgTcVR/djWDB9Msb2xMkhdw sR6teidRkEnEeK7HF6F7023/O/SYIrkOo3OpOqtxq9tJD+b73VB3oRgnOOst6IMna5bu Xvog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=/5wZNJtp2mX8NfBRTYQuZh4HmOw71AFLZUW10N+aBsQ=; b=Gt7eUKOjSGI3+56eBdfcLTNIh6UB4iIfuc3dpEbvh1PdtWc1ykikJXP5nEQVrfxKA2 rsfSCzbyE1PIiMC5jxAu7M7OKnF8YV6LdS/50WtovC22vpj+ogu1NjupYclV5kldA9hb C1N2nu/teuxHWVPxqIaBuFV4G2rE96YLGTMzuya5cp9iFGnzUS8KJkvbDuTcp1O85Fl6 1q88ZNykv6eaeDG1F1RAY/G4NqmNhwDCnqlYCNJ8ub7BwC6dH4S2OEK5yifCFwuxq6vD /yFfFlapoBlho9diRXvn2YLWB8mNNGqNrl4hFhVeHQoUDeLucgBIaDUBVb+ZU/kcof5w rXdw== X-Gm-Message-State: AGi0Puaz4tVU0iot5JNDhq8xvVeMvxxTzFvsQtRAUVSXJ+cYjjGgQ46+ 50AiGyNQDnYH4f21ztKHzaQmLQ== X-Google-Smtp-Source: APiQypJ7tLc3311jkHJQB8oAgiPSZQrzQH63SFUyWZSmWpSmGOX4QH8py5zaYrarM/HuyQiJUB/zZw== X-Received: by 2002:a37:9b4f:: with SMTP id d76mr13634362qke.305.1588091385145; Tue, 28 Apr 2020 09:29:45 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([190.95.18.252]) by smtp.gmail.com with ESMTPSA id e4sm13375520qkn.11.2020.04.28.09.29.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 09:29:43 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id B955730076A; Tue, 28 Apr 2020 12:29:41 -0400 (-04) Date: Tue, 28 Apr 2020 12:29:41 -0400 From: Alvaro Herrera To: Kyotaro Horiguchi Cc: jgdr@dalibo.com, andres@anarazel.de, michael@paquier.xyz, sawada.mshk@gmail.com, peter.eisentraut@2ndquadrant.com, pgsql-hackers@lists.postgresql.org, thomas.munro@enterprisedb.com, sk@zsrv.org, michael.paquier@gmail.com Subject: Re: [HACKERS] Restricting maximum keep segments by repslots Message-ID: <20200428162941.GA6196@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200428.135857.1243584941650464602.horikyota.ntt@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-Apr-28, Kyotaro Horiguchi wrote: > At Mon, 27 Apr 2020 18:33:42 -0400, Alvaro Herrera wrote in > > On 2020-Apr-08, Kyotaro Horiguchi wrote: > > > > > At Wed, 08 Apr 2020 09:37:10 +0900 (JST), Kyotaro Horiguchi wrote in > > Thanks for the fix! I propose two changes: > > > > 1. reword the error like this: > > > > ERROR: replication slot "regression_slot3" cannot be advanced > > DETAIL: This slot has never previously reserved WAL, or has been invalidated > > Agreed to describe what is failed rather than the cause. However, > logical replications slots are always "previously reserved" at > creation. Bah, of course. I was thinking in making the equivalent messages all identical in all callsites, but maybe they should be different when slots are logical. I'll go over them again. > > 2. use the same error in one other place, to wit > > pg_logical_slot_get_changes() and pg_replication_slot_advance(). I > > made the DETAIL part the same in all places, but the ERROR line is > > adjusted to what each callsite is doing. > > I do think that this change in test_decoding is a bit unpleasant: > > > > -ERROR: cannot use physical replication slot for logical decoding > > +ERROR: cannot get changes from replication slot "repl" > > > > The test is > > -- check that we're detecting a streaming rep slot used for logical decoding > > SELECT 'init' FROM pg_create_physical_replication_slot('repl'); > > SELECT data FROM pg_logical_slot_get_changes('repl', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1'); > > The message may be understood as "No change has been made since > restart_lsn". Does something like the following work? > > ERROR: replication slot "repl" is not usable to get changes That wording seems okay, but my specific point for this error message is that we were trying to use a physical slot to get logical changes; so the fact that the slot has been invalidated is secondary and we should complain about the *type* of slot rather than the restart_lsn. > By the way there are some other messages that doesn't render the > symptom but the cause. > > "cannot use physical replication slot for logical decoding" > "replication slot \"%s\" was not created in this database" > > Don't they need the same amendment? Maybe, but I don't want to start rewording every single message in uses of replication slots ... I prefer to only modify the ones related to the problem at hand. > > > > On the other hand, physical replication doesn't break by invlidation. > > > > [...] > > Anyway I think the current patch can be applied as is -- and if we want > > physical replication to have some other behavior, we can patch for that > > afterwards. > > Agreed here. The false-invalidation doesn't lead to any serious > consequences. But does it? What happens, for example, if we have a slot used to get a pg_basebackup, then time passes before starting to stream from it and is invalidated? I think this "works fine" (meaning that once we try to stream from the slot to replay at the restored base backup, we will raise an error immediately), but I haven't tried. The worst situation would be producing a corrupt replica. I don't think this is possible. The ideal behavior I think would be that pg_basebackup aborts immediately when the slot is invalidated, to avoid wasting more time producing a doomed backup. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services