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 1pIJ8J-0004hp-Ic for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Jan 2023 00:50:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pIJ8I-0001lK-9U for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Jan 2023 00:50:22 +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 1pIJ8H-0001kW-V6 for pgsql-hackers@lists.postgresql.org; Thu, 19 Jan 2023 00:50:22 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pIJ8E-00059H-5A for pgsql-hackers@lists.postgresql.org; Thu, 19 Jan 2023 00:50:20 +0000 Received: by mail-pj1-x1035.google.com with SMTP id o7-20020a17090a0a0700b00226c9b82c3aso284700pjo.3 for ; Wed, 18 Jan 2023 16:50:18 -0800 (PST) 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=eOOz1r987x61nGPcaJvv/E3Kd7YE3XMrDkI6XUySyno=; b=KSquibUMWtjMWGvAlLEEJ8KnEgd6bg0Ju0JIQBAbpTg8WAyFqTdGn3VTobYyd7NzoD 4yiC17JI7mnNyQE7IwRouBnipBMY1xs1LPFX4L1uaNreJlumrAd4qQRSWvz6lV+LAgi7 4CMLDzYMrt2jH1oefJrK8gk3l2YJ2SrKa1bupp1rbN8Nz9dPPedkip7bLBJJZ4lZFyGn GmC6JwlXzkxfUwrcd2/Erj9qN3TwXuu2UQJdK8Cl6JlP/fSuLN4cfQL37INipKfjzwon ZAib+6MhcGefBnyABWxGl1dFASe7U/NoniWkguUpxzjFmmwHFqOIoC/QK7HuZ+98r+yX jmmg== 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=eOOz1r987x61nGPcaJvv/E3Kd7YE3XMrDkI6XUySyno=; b=vGc1WmbYOHzbgWQ0by/t/yDKcpmFVZuptQt+Uq6FXMYYLsNLeglE5ycs6OExZGmMKA UcYXMHJXxk6UKK2EYwcGOSVAOZs7FB/dLwTGlAViNQ9ovrSnnPFJBVFt8lNpd7N3m8cz 2DNkvJwOkH4EedR2N+cQY6lHnpea6iPcE/7U/pRTfY9hYO/a21TiB8KNndQRPapPBWb9 94Oyz0Dj9Fu8Hd4jfrdl2+i+Bh/UpnXJaLhRpqU5zihC3Bl5w/Oucwrv+yUJERossF+V GmVFR57poQKmSv7/qHEWVWjJKmrWTF1WiNl6UYCTpBzVZ6iz5b2Fz9bKKq7ouJ/hZURu VhuQ== X-Gm-Message-State: AFqh2krZa+qFhSXo4w7EsorjMMr3UhRwCOS5Koxlrwz623B+5vv1XaCL xvV0RB7Juf+oQLhk5n3m7jo= X-Google-Smtp-Source: AMrXdXuJHPjqUgQtrkT9RlL50WcEx63aiXavLIGF9oEGgi9VNKObPO4AkDTdOd0Il7+orgfBdkboRw== X-Received: by 2002:a05:6a20:4fa9:b0:b8:3264:122b with SMTP id gh41-20020a056a204fa900b000b83264122bmr9408906pzb.15.1674089417221; Wed, 18 Jan 2023 16:50:17 -0800 (PST) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id w11-20020a627b0b000000b0058b59c81a29sm14356905pfc.220.2023.01.18.16.50.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 16:50:16 -0800 (PST) Date: Wed, 18 Jan 2023 16:50:14 -0800 From: Nathan Bossart To: Bharath Rupireddy Cc: Kyotaro Horiguchi , Cary Huang , PostgreSQL Hackers , SATYANARAYANA NARLAPURAM Subject: Re: Switching XLog source from archive to streaming when primary available Message-ID: <20230119005014.GA3838170@nathanxps13> References: <20221008215221.GA894639@nathanxps13> <20221009214725.GD900071@nathanxps13> <20221011031001.GC1322187@nathanxps13> <20230112005114.GB2032194@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 Tue, Jan 17, 2023 at 07:44:52PM +0530, Bharath Rupireddy wrote: > On Thu, Jan 12, 2023 at 6:21 AM Nathan Bossart wrote: >> With your patch, we might replay one of these "old" files in pg_wal instead >> of the complete version of the file from the archives, > > That's true even today, without the patch, no? We're not changing the > existing behaviour of the state machine. Can you explain how it > happens with the patch? My point is that on HEAD, we will always prefer a complete archive file. With your patch, we might instead choose to replay an old file in pg_wal because we are artificially advancing the state machine. IOW even if there's a complete archive available, we might not use it. This is a behavior change, but I think it is okay. >> Would you mind testing this scenario? > > How about something like below for testing the above scenario? If it > looks okay, I can add it as a new TAP test file. > > 1. Generate WAL files f1 and f2 and archive them. > 2. Check the replay lsn and WAL file name on the standby, when it > replays upto f2, stop the standby. > 3. Set recovery to fail on the standby, and stop the standby. > 4. Generate f3, f4 (partially filled) on the primary. > 5. Manually copy f3, f4 to the standby's pg_wal. > 6. Start the standby, since recovery is set to fail, and there're new > WAL files (f3, f4) under its pg_wal, it must replay those WAL files > (check the replay lsn and WAL file name, it must be f4) before > switching to streaming. > 7. Generate f5 on the primary. > 8. The standby should receive f5 and replay it (check the replay lsn > and WAL file name, it must be f5). > 9. Set streaming to fail on the standby and set recovery to succeed. > 10. Generate f6 on the primary. > 11. The standby should receive f6 via archive and replay it (check the > replay lsn and WAL file name, it must be f6). I meant testing the scenario where there's an old file in pg_wal, a complete file in the archives, and your new GUC forces replay of the former. This might be difficult to do in a TAP test. Ultimately, I just want to validate the assumptions discussed above. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com