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 1ohe92-0000ly-3G for pgsql-hackers@arkaria.postgresql.org; Sun, 09 Oct 2022 21:47:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ohe8z-0000wI-MN for pgsql-hackers@arkaria.postgresql.org; Sun, 09 Oct 2022 21:47:33 +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 1ohe8z-0000w9-Bf for pgsql-hackers@lists.postgresql.org; Sun, 09 Oct 2022 21:47:33 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ohe8w-0002YA-1v for pgsql-hackers@lists.postgresql.org; Sun, 09 Oct 2022 21:47:32 +0000 Received: by mail-pf1-x434.google.com with SMTP id 3so7746887pfw.4 for ; Sun, 09 Oct 2022 14:47:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=QjzU+X+ho11VUK9bE5vOgfjFaGTv+VXk3HMDOPtxxCQ=; b=Mth8l2p1N8mc8BCRe8sLMN865OnLEJFqrAePfeSQowu6RrQamSJw54ZHrvXgBQ66Gx x79nTzerIwAI4e64nZRCOaSVfbK76Q9Gp1HUhoKd4jiApVxX5FqrVa/GGiSyrXl8+hrE EfO/dJZZy+HEPBv6QEdwqms+qtiZOUCgLygSV9QQHUnuQAWtKHyjWEizTNGNvFA5IeOh AnfcZLB5kmfM/0lDWTjQOAvG+y7mssyBC3ZfzxWqar2aBELoKRYWZ+y365SwD87KQoVO AcQuJTVqQBM8SmJyFeveRG3X8GstG7pgTF/RrTBO7nR37b1NiArhcVfDQACF9TvT/NVw 3PMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=QjzU+X+ho11VUK9bE5vOgfjFaGTv+VXk3HMDOPtxxCQ=; b=pB3rkiE2CMeOguSP4lLW3qrHaSuUbmi5QB43V0HsaBBd4jsbuEJw62bynlBFvTY/jL c7kknq8o1pjjvzu6T2kTGG0UlmCUV4wDugeIvwV4sYCwu9dcQgai0UIVTUbJ5fg0JXjg SGsstfKlpiECMPy9/xPOQzhr93ishW10B5XN8f+NxflkNdmEI+qJcEHRvg3Q41QX5uvo MPMLDRgRcNc3vVzS8n/gYb0h3TOHob1Nm98ssuGvq5VK7+MO/Mpm9NVz8nTHAkedGzlW 2m60QOKbLGjcMRJ3zcy5okjxPKU9/6ByZvCGQ4vbIDtcQitNf8sTxnZYRUbQNbLATKSd cT8Q== X-Gm-Message-State: ACrzQf36zxFEJQ3EAvoDAmHysptbe1E16udqX1+E5v6Ofsi6vDe89O4F o9vu5LoKzJUPuI+owqev0TE= X-Google-Smtp-Source: AMsMyM6JDCk4XoTyWyj+d9XV+Znr/Kf4epu7WRoVleUY5LNYgK5wpFJjBZDDj4MINl8V+gqB6CUkeQ== X-Received: by 2002:a05:6a00:7ce:b0:562:b271:9854 with SMTP id n14-20020a056a0007ce00b00562b2719854mr15499761pfu.46.1665352047794; Sun, 09 Oct 2022 14:47:27 -0700 (PDT) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id 65-20020a630244000000b0045913a96837sm5038414pgc.24.2022.10.09.14.47.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Oct 2022 14:47:27 -0700 (PDT) Date: Sun, 9 Oct 2022 14:47:25 -0700 From: Nathan Bossart To: Bharath Rupireddy Cc: Kyotaro Horiguchi , cary.huang@highgo.ca, pgsql-hackers@lists.postgresql.org, satyanarlapuram@gmail.com Subject: Re: Switching XLog source from archive to streaming when primary available Message-ID: <20221009214725.GD900071@nathanxps13> References: <20220915.172207.1940822794018442836.horikyota.ntt@gmail.com> <20220916.153629.1624554489607517175.horikyota.ntt@gmail.com> <20221008215221.GA894639@nathanxps13> 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: Archived-At: Precedence: bulk On Sun, Oct 09, 2022 at 02:39:47PM +0530, Bharath Rupireddy wrote: > We can give it a chance to restore from pg_wal before switching to > streaming to not change any behaviour of the state machine. But, not > definitely by setting currentSource to XLOG_FROM_WAL, we basically > never explicitly set currentSource to XLOG_FROM_WAL, other than when > not in archive recovery i.e. InArchiveRecovery is false. Also, see the > comment [1]. > > Instead, the simplest would be to just pass XLOG_FROM_WAL to > XLogFileReadAnyTLI() when we're about to switch the source to stream > mode. This doesn't change the existing behaviour. It might be more consistent with existing behavior, but one thing I hadn't considered is that it might make your proposed feature ineffective when users are copying files straight into pg_wal. IIUC as long as the files are present in pg_wal, the source-switch logic won't kick in. > Unrelated to this patch, the fact that the standby polls pg_wal is not > documented or recommended, is not true, it is actually documented [2]. > Whether or not we change the docs to be something like [3], is a > separate discussion. I wonder if it would be better to simply remove this extra polling of pg_wal as a prerequisite to your patch. The existing commentary leads me to think there might not be a strong reason for this behavior, so it could be a nice way to simplify your patch. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com