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 1ojPUm-0001wP-3C for pgsql-hackers@arkaria.postgresql.org; Fri, 14 Oct 2022 18:33:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ojPUj-0005sE-NJ for pgsql-hackers@arkaria.postgresql.org; Fri, 14 Oct 2022 18:33:17 +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 1ojPUj-0005s4-AE for pgsql-hackers@lists.postgresql.org; Fri, 14 Oct 2022 18:33:17 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ojPUg-00038n-Ox for pgsql-hackers@postgresql.org; Fri, 14 Oct 2022 18:33:16 +0000 Received: by mail-pj1-x102d.google.com with SMTP id gf8so5660166pjb.5 for ; Fri, 14 Oct 2022 11:33:14 -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=cuypQTt2G6aqWZfjRjn4JgK7BimUCau+V3uQq9nfpbI=; b=H9wmFHJVfHNyH/lxCqwY/GhDP2BkLub+/tf4F6msgVtI3jiTaOY3MgeokkPZPBI2H3 fYwjXRxrxNlwD1ksizticdqdi+6KXeS54KnSbRJNu+oWaGre83crYs7riXxPrfrXb2uk J5CclVTr9GQJprkA3BsETfc9BdgTR1BaFI0IXz+LUyEIKffNGv+nsSTLhF/jmyborzIx gp8kQ/jfUNUnCgh9L1M6nRHkMwswDMIA/lcHIYE/S7mTIl8nYytS7vIGwu0I+qfjv0VI 3K7o88qg85ELmrdsqgvRknwAZyE3YtKkYVr+8nNIKjehtJTfvEWNm8QWCvc/aUzh5kc6 3jJQ== 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=cuypQTt2G6aqWZfjRjn4JgK7BimUCau+V3uQq9nfpbI=; b=4Vs0Ikj/6Ze46DLhnlWFLr8dBFbfcauBG0ynRoBUg1loNYylUZeJ64XH+XZGqbmmVN ZIR1IfeZtXfnzA1dfoVCU42s3g2djUye0FCv/4yo02KGdw/+CUfBc1LGXdTm9xYJHcKh pogGku0iUF7PIZoVgEJSQJy/39ey5bmjXcVz8TVGHrJY8qP13wjvUvZ0STONYCPocikV iqLT5Y41vzLO9U2dPGyLwvTCXz2NyAKfN5CEa6NLXnJb51vTUL73M6El69SWPJdPX8ZM wCvtYfyBX9y9eg9EOhYqNzE3rN9nAdmDpOqAb7NrMvsUp/r1ep1gsPsLeRtz33lS56SY 8eDQ== X-Gm-Message-State: ACrzQf3rmX30QTSyExQZ+FzboNfVybUii6RD2z0JJL2MyK1D//KEnxa2 gr4CMY7j6Ghke9zi3r9RTNb5+ZbJoyE= X-Google-Smtp-Source: AMsMyM6hKYD4cR+3cxck8wj3DsLuhKWMtXrwefXTuZZabgecfLksfLH48NkzoR+ASq+tyrIIQ9CXWg== X-Received: by 2002:a17:902:db09:b0:184:ba4f:af28 with SMTP id m9-20020a170902db0900b00184ba4faf28mr6312478plx.145.1665772393665; Fri, 14 Oct 2022 11:33:13 -0700 (PDT) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id a15-20020a1709027e4f00b0017f92246e4dsm2016700pln.181.2022.10.14.11.33.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 11:33:13 -0700 (PDT) Date: Fri, 14 Oct 2022 11:33:10 -0700 From: Nathan Bossart To: Bharath Rupireddy Cc: pgsql-hackers@postgresql.org Subject: Re: thinko in basic_archive.c Message-ID: <20221014183310.GB1678424@nathanxps13> References: <20221014044106.GA1673343@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 Fri, Oct 14, 2022 at 02:15:19PM +0530, Bharath Rupireddy wrote: > Given that temp file name includes WAL file name, epoch to > milliseconds scale and MyProcPid, can there be name collisions after a > server crash or even when multiple servers with different pids are > archiving/copying the same WAL file to the same directory? While unlikely, I think it's theoretically possible. If there is a collision, archiving should fail and retry later with a different temporary file name. > What happens to the left-over temp files after a server crash? Will > they be lying around in the archive directory? I understand that we > can't remove such files because we can't distinguish left-over files > from a crash and the temp files that another server is in the process > of copying. The temporary files are not automatically removed after a crash. The documentation for basic archive has a note about this [0]. > If the goal is to copy files atomically, why can't we name the temp > file 'wal_file_name.pid.temp', assuming no PID wraparound and get rid > of appending time? Since basic_archive is a test module illustrating > archive_library implementation, do we really need to worry about name > collisions? Yeah, it's debatable how much we care about this for basic_archive. We previously decided that we at least care a little [1], so that's why we have such elaborate temporary file names. If anything, I hope that the presence of this logic causes archive module authors to think about these problems. > The patch LGTM. Thanks! [0] https://www.postgresql.org/docs/devel/basic-archive.html#id-1.11.7.15.6 [1] https://postgr.es/m/CA%2BTgmoaSkSmo22SwJaV%2BycNPoGpxe0JV%3DTcTbh4ip8Cwjr0ULQ%40mail.gmail.com -- Nathan Bossart Amazon Web Services: https://aws.amazon.com