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 1pKUr0-0003kW-Rj for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Jan 2023 01:45:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pKUqz-0001iO-OK for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Jan 2023 01:45:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pKUqz-0001iF-FC for pgsql-hackers@lists.postgresql.org; Wed, 25 Jan 2023 01:45:33 +0000 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pKUqw-0004Ko-TP for pgsql-hackers@postgresql.org; Wed, 25 Jan 2023 01:45:32 +0000 Received: by mail-pf1-x42e.google.com with SMTP id 207so12454864pfv.5 for ; Tue, 24 Jan 2023 17:45:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:from:subject:cc:to:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=GF+ItmiyEN4N1uaS/vcts0xbYxsTmV9C4VxMwwN6uoc=; b=LKwe8EhRcRN1ny4NDw7BY0VToloIfbJnmL4zZ3ITFpORog9DE3FGFBwirmrflX1c5y YpZvAaw0X+wdSbQUwd0qPqYDBiTOKlwsGhDIrhI68+kKxhkblqHpzMzTHiOWYdUdF3qa MJjs11+jPqJNdT9nDdJ1zCTLYbPFWkxnBDk9PgTGUKSn3oLL2hd2rH9E2Xt+hjQ9FaEY p+igDnKURDwD+Jah80R2DgGPyqP4B0a0ybx/95svQoIsunJlklKmGOOUce5rGbBxVYZr eeScyg1M/mXLVoLbOJrHx8nX/i5xbD6fg6kRaPiITHa2QW5ITRZ8xLsUbcZ/ufV+1EuP cgDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:from:subject:cc:to:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=GF+ItmiyEN4N1uaS/vcts0xbYxsTmV9C4VxMwwN6uoc=; b=bPea/Q1+akUqNDIH+NiGJhqdJ6ZG85YHZIBuOJ8Rxcvp7Qphoh4QDOa6i7h6rOZoOQ SLeYSaFNvCpX44bewYx4ETRAd5t4FjpEAMrp97EgYMR0ahwwtiipTIi1EbZt2yXLgYCA siI7GfKdeCEfKRYLuqPCNCf9h+pZhNRGn4kifBkL7vhTFTxmvd5x5ORZlwlwz0/xqJxy ljoqLNUS4k2u1MpCloocGzJOggKlzgfbAF4veVTGcqMiVP/5k6YNFtpCH93VHdIdpgU2 RqevTXMCpN+vdeT0jgudxlwaIta0I3xPfsBe25OXCS7GU718QK2/K+ADDTGIaNdpetXa qapQ== X-Gm-Message-State: AFqh2krOGvYiv+A60mYyeTnMIQN1NT56QweR+5qGBmHpnytqpOHGfMEJ m2OZ8h+HRe7zURyBk20gqDA= X-Google-Smtp-Source: AMrXdXsPMhk+sfdZosrvRz9Av5iaeOwAFZvorkGDLp4WYPg3oPOrwzIPZaeZMwBKh5zKgb8R8RQWyw== X-Received: by 2002:a05:6a00:1887:b0:58c:b0a:e504 with SMTP id x7-20020a056a00188700b0058c0b0ae504mr40499824pfh.18.1674611129887; Tue, 24 Jan 2023 17:45:29 -0800 (PST) Received: from localhost (KD036014041111.ppp-bb.dion.ne.jp. [36.14.41.111]) by smtp.gmail.com with ESMTPSA id h16-20020aa786d0000000b0058cda506a4fsm2331347pfo.145.2023.01.24.17.45.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 24 Jan 2023 17:45:29 -0800 (PST) Date: Wed, 25 Jan 2023 10:45:25 +0900 (JST) Message-Id: <20230125.104525.433115861591453756.horikyota.ntt@gmail.com> To: kuroda.hayato@fujitsu.com Cc: amit.kapila16@gmail.com, osumi.takamichi@fujitsu.com, smithpb2250@gmail.com, vignesh21@gmail.com, shveta.malik@gmail.com, dilipbalaut@gmail.com, euler@eulerto.com, m.melihmutlu@gmail.com, andres@anarazel.de, marcos@f10.com.br, pgsql-hackers@postgresql.org Subject: Re: Time delayed LR (WAS Re: logical replication restrictions) From: Kyotaro Horiguchi In-Reply-To: References: <20230124.114535.1107425862791533999.horikyota.ntt@gmail.com> User-Agent: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Sorry for making you bothered by this. At Tue, 24 Jan 2023 10:12:40 +0000, "Hayato Kuroda (Fujitsu)" wrote in > > > Couldn't we maintain an additional static variable "last_applied" > > > along with last_received? > > > > > > > It won't be easy to maintain the meaning of last_applied because there > > are cases where we don't apply the change directly. For example, in > > case of streaming xacts, we will just keep writing it to the file, > > now, say, due to some reason, we have to send the feedback, then it > > will not allow you to update the latest write locations. This would > > then become different then what we are doing without the patch. > > Another point to think about is that we also need to keep the variable > > updated for keep-alive ('k') messages even though we don't apply > > anything in that case. Still, other cases to consider are where we > > have mix of streaming and non-streaming transactions. > > I have tried to implement that, but it might be difficult because of a corner > case related with the initial data sync. > > First of all, I have made last_applied to update when > > * transactions are committed, prepared, or aborted > * apply worker receives keepalive message. Yeah, I vagurly thought that it is enough that the update happens just befor existing send_feecback() calls. But it turned out to introduce another unprincipledness.. > I thought during the initial data sync, we must not update the last applied > triggered by keepalive messages, so following lines were added just after > updating last_received. > > ``` > + if (last_applied < end_lsn && AllTablesyncsReady()) > + last_applied = end_lsn; > ``` Maybe, the name "last_applied" made you confused. As I mentioned in another message, the variable points to the remote LSN of last "processed" 'w/k' messages. regards. -- Kyotaro Horiguchi NTT Open Source Software Center