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 1iwSRW-0007PB-Pd for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Jan 2020 15:06:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iwSRV-0007Qw-Kg for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Jan 2020 15:06:17 +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 1iwSRV-0007Qe-5t for pgsql-hackers@lists.postgresql.org; Tue, 28 Jan 2020 15:06:17 +0000 Received: from cyclops.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1iwSRN-0001K4-Ic for pgsql-hackers@postgresql.org; Tue, 28 Jan 2020 15:06:15 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 1796B21C5F42; Tue, 28 Jan 2020 18:06:07 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from [192.168.27.223] (gw.postgrespro.ru [93.174.131.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id B9DD821C5F38; Tue, 28 Jan 2020 18:06:06 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1580223966; bh=cnaCYgQAuZTmlMnKFNOqEVQ4Ows5EDtDcIhJo2aNe54=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=kzkx13P+b92TU7Mx4h5Q2NBgs+hrdbe9hhuXuu7NUwxEjoA/yL51LQe83HlsNRCxr HBKEGoFRuRtm7HWoiZY+LOR7Bzj8tqXlHZuBknVr5wXDz7TlStwGyOKVuznihJhgch 0SsHUtjtlEXUePbqisgwXSyFdoUqOagZXAvmlB4o= Subject: Re: Physical replication slot advance is not persistent To: Kyotaro Horiguchi , craig@2ndquadrant.com Cc: michael@paquier.xyz, andres@anarazel.de, pgsql-hackers@postgresql.org, simon@2ndquadrant.com References: <20200121050730.GF2552@paquier.xyz> <20200128080114.GB145179@paquier.xyz> <20200128.211434.296322058369197735.horikyota.ntt@gmail.com> From: Alexey Kondratov Message-ID: <4e060856-dfca-eb31-f60d-616378de3edd@postgrespro.ru> Date: Tue, 28 Jan 2020 18:06:06 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <20200128.211434.296322058369197735.horikyota.ntt@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 28.01.2020 15:14, Kyotaro Horiguchi wrote: > At Tue, 28 Jan 2020 17:45:47 +0800, Craig Ringer wrote in >> On Tue, 28 Jan 2020 at 16:01, Michael Paquier wrote: >>> So attached is an updated patch which addresses the problem just by >>> marking a physical slot as dirty if any advancing is done. Some >>> documentation is added about the fact that an advance is persistent >>> only at the follow-up checkpoint. And the tests are fixed to not use >>> a fake LSN but instead advance to the latest LSN position produced. >>> >>> Any objections? >> LGTM. Thankyou. > I agree not to save slots immediately. The code is wrtten as described > above. The TAP test is correct. +1, removing this broken saving code path from pg_replication_slot_advance and marking slot as dirty looks good to me. It solves the issue and does not add any unnecessary complexity. > > But the doc part looks a bit too detailed to me. Couldn't we explain > that without the word 'dirty'? > > - and it will not be moved beyond the current insert location. Returns > - name of the slot and real position to which it was advanced to. > + and it will not be moved beyond the current insert location. Returns > + name of the slot and real position to which it was advanced to. The > + updated slot is marked as dirty if any advancing is done, with its > + information being written out at the follow-up checkpoint. In the > + event of a crash, the slot may return to an earlier position. > > and it will not be moved beyond the current insert location. Returns > name of the slot and real position to which it was advanced to. The > information of the updated slot is scheduled to be written out at the > follow-up checkpoint if any advancing is done. In the event of a > crash, the slot may return to an earlier position. Just searched through the *.sgml files, we already use terms 'dirty' and 'flush' applied to writing out pages during checkpoints. Here we are trying to describe the very similar process, but in relation to replication slots, so it looks fine for me. In the same time, the term 'schedule' is used for VACUUM, constraint check or checkpoint itself. Regards -- Alexey Kondratov Postgres Professional https://www.postgrespro.com Russian Postgres Company