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 1o78nT-0006uC-9l for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Jul 2022 05:02:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o78nS-0006u1-0F for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Jul 2022 05:02:26 +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 1o78nR-0006ts-N3 for pgsql-hackers@lists.postgresql.org; Fri, 01 Jul 2022 05:02:25 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o78nM-0002pu-8Q for pgsql-hackers@lists.postgresql.org; Fri, 01 Jul 2022 05:02:25 +0000 Received: from [10.6.216.36] (unknown [203.180.48.65]) by oss.nttdata.com (Postfix) with ESMTPSA id DF9696033C; Fri, 1 Jul 2022 14:02:14 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.6 at oss.nttdata.com Message-ID: <26aa6466-5a85-6f63-dfc9-24cd1cf36502@oss.nttdata.com> Date: Fri, 1 Jul 2022 14:02:14 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: Backup command and functions can cause assertion failure and segmentation fault Content-Language: en-US To: Kyotaro Horiguchi Cc: pgsql-hackers@lists.postgresql.org References: <3374718f-9fbf-a950-6d66-d973e027f44c@oss.nttdata.com> <20220701.114653.401585706513489837.horikyota.ntt@gmail.com> <20220701.115614.908767952051113921.horikyota.ntt@gmail.com> <20220701.120537.503466015850285563.horikyota.ntt@gmail.com> From: Fujii Masao In-Reply-To: <20220701.120537.503466015850285563.horikyota.ntt@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2022/07/01 12:05, Kyotaro Horiguchi wrote: > At Fri, 01 Jul 2022 11:56:14 +0900 (JST), Kyotaro Horiguchi wrote in >> At Fri, 01 Jul 2022 11:46:53 +0900 (JST), Kyotaro Horiguchi wrote in >>> Please find the attached. >> >> Mmm. It forgot the duplicate-call prevention and query-cancel >> handling... The first one is the same as you posted but the second one >> is still a problem.. > > So this is the first cut of that. Thanks for reviewing the patch! + PG_FINALLY(); + { endptr = do_pg_backup_stop(labelfile->data, !opt->nowait, &endtli); } - PG_END_ENSURE_ERROR_CLEANUP(do_pg_abort_backup, BoolGetDatum(false)); - + PG_END_TRY(); This change makes perform_base_backup() call do_pg_backup_stop() even when an error is reported while taking a backup, i.e., between PG_TRY() and PG_FINALLY(). Why do_pg_backup_stop() needs to be called in such an error case? It not only cleans up the backup state but also writes the backup-end WAL record, waits for WAL archiving. In an error case, I think that only the cleanup of the backup state is necessary. So it seems ok to use do_pg_abort_backup() in that case, as it is for now. So I'm still thinking that the patch I posted is simpler and enough. Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION