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 1orR0L-0007Zi-9p for pgsql-hackers@arkaria.postgresql.org; Sat, 05 Nov 2022 21:47:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1orR0J-0004sO-Mn for pgsql-hackers@arkaria.postgresql.org; Sat, 05 Nov 2022 21:47:03 +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 1orR0J-0004sF-Ac for pgsql-hackers@lists.postgresql.org; Sat, 05 Nov 2022 21:47:03 +0000 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1orR0C-0003Y6-Jq for pgsql-hackers@postgresql.org; Sat, 05 Nov 2022 21:47:02 +0000 Received: by mail-pg1-x52c.google.com with SMTP id h193so7243229pgc.10 for ; Sat, 05 Nov 2022 14:46:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=FTuGHK86MjVCxqz3ZNdQqDyYNl+oUIUuht2yzUV7dYk=; b=jrTBrLYg9Pj5RE3E+xfG2SQcDbOiONFbnE0Wa6xpC6k6ogiiuZNPcTVD2krVM8mm2J C/ivrqnlcJrfw+aBQ3LOZsE2jpVc5aI/gDExefJzYJiuCSOZ1JO5R9EH1avkDJyAFcU5 Ef63nes+ddF11HdL7WEqdUCU8m6BAb4k+8a2sRwcR86UyMVZAWegUa8HDasSHE6N/FoY O4pZljTjWxP/3k1RA9yGrEzITb0RHLFFyRl2kwKXCYq5GCMucE5jT8rG2d8C/ABti+4S MVIRT6/SwuoNYb72VGX4cqGgO+1cTC0op4m9zSUZA/CrKXMHZJKhb/p4ghcP6bolx4uy 7AWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding: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=FTuGHK86MjVCxqz3ZNdQqDyYNl+oUIUuht2yzUV7dYk=; b=PcA48AtamCcLW5s/tbzNTTrGSj3LbxL1rRpfKTNkV5N3zXWu8O/GMjQurjuKeo1MO6 6T3rQMvxSv6+/8FquI817tg4m/JXUYqT8DOv/0qA8YmJg91avORotG0oFv2XQfv77TW/ IkLtgw8qMIBrI+52WJqAgDFwoqXLr7eze0IgHgh9gd6vLqN/za9f6VX8eO6A+0GvWX7d EokgK69Gtr60s9DC7Lj8yXr/v+7Fd9ri1gY+NUP8BccxvjicSqL9esU2w1u13n5wpoUW RC/dvFCezcGygwgm9ubxOSG+BDoL6OEkOYrcylTw9hGJTyDYlkfLYejIAjSPHMuf8vd4 JcsQ== X-Gm-Message-State: ACrzQf3/8fUy2yz7OdXrlm5DdniA6WPV65zhCIoK9q5ra9h4w9sd+yKl hQyOW5zgMw8x2zcmVdxIbpA= X-Google-Smtp-Source: AMsMyM4xWHrBVQZAhV/UOAX4EK6prrKPQllaR/x3dZb9WigkRwLP+xrGvSxbJzLl+p49R3zxfvZxwQ== X-Received: by 2002:a63:e44d:0:b0:44e:d36e:499a with SMTP id i13-20020a63e44d000000b0044ed36e499amr557078pgk.216.1667684814582; Sat, 05 Nov 2022 14:46:54 -0700 (PDT) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id z5-20020a17090a398500b0020647f279fbsm3494942pjb.29.2022.11.05.14.46.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Nov 2022 14:46:53 -0700 (PDT) Date: Sat, 5 Nov 2022 14:46:51 -0700 From: Nathan Bossart To: Bharath Rupireddy Cc: Kyotaro Horiguchi , robertmhaas@gmail.com, pgsql-hackers@postgresql.org Subject: Re: thinko in basic_archive.c Message-ID: <20221105214651.GC137360@nathanxps13> References: <20221020.102647.746666963360821887.horikyota.ntt@gmail.com> <20221021.141346.1491472262189507263.horikyota.ntt@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Oct 21, 2022 at 09:30:16PM +0530, Bharath Rupireddy wrote: > On Fri, Oct 21, 2022 at 10:43 AM Kyotaro Horiguchi > wrote: >> Thanks, but we don't need to wipe out the all bytes. Just putting \0 >> at the beginning of the buffer is sufficient. > > Nah, that's not a clean way IMO. Why not? This is a commonly-used technique. I see over 80 existing useѕ in PostgreSQL. Plus, your shutdown callback only checks for the first byte, anyway. + if (tempfilepath[0] == '\0') + return; As noted upthread [0], I think we should be cautious to only remove the temporary file if we know we created it. I still feel that trying to add this cleanup logic to basic_archive is probably more trouble than it's worth, but if there is a safe and effective way to do so, I won't object. [0] https://postgr.es/m/20221015211026.GA1821022%40nathanxps13 -- Nathan Bossart Amazon Web Services: https://aws.amazon.com