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 1o7AD6-0002pk-UV for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Jul 2022 06:33:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o7AD4-0004eu-RN for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Jul 2022 06:32:58 +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 1o7AD4-0004ee-Hi for pgsql-hackers@lists.postgresql.org; Fri, 01 Jul 2022 06:32:58 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o7AD1-0000yn-By for pgsql-hackers@lists.postgresql.org; Fri, 01 Jul 2022 06:32:57 +0000 Received: from [10.6.216.36] (unknown [203.180.48.65]) by oss.nttdata.com (Postfix) with ESMTPSA id 2367B6033C; Fri, 1 Jul 2022 15:32:51 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.6 at oss.nttdata.com Content-Type: multipart/mixed; boundary="------------avCMetnnSAkqo3zkCP7pEppT" Message-ID: <6a759108-a02c-34fd-856c-d7c09d29d2ba@oss.nttdata.com> Date: Fri, 1 Jul 2022 15:32:50 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: Backup command and functions can cause assertion failure and segmentation fault Content-Language: en-US To: Masahiko Sawada Cc: pgsql-hackers@lists.postgresql.org References: <3374718f-9fbf-a950-6d66-d973e027f44c@oss.nttdata.com> From: Fujii Masao In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------avCMetnnSAkqo3zkCP7pEppT Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2022/07/01 15:09, Masahiko Sawada wrote: > The change looks good to me. I've also confirmed the change fixed the issues. Thanks for the review and test! > @@ -233,6 +233,12 @@ perform_base_backup(basebackup_options *opt, bbsink *sink) > StringInfo labelfile; > StringInfo tblspc_map_file; > backup_manifest_info manifest; > + SessionBackupState status = get_backup_status(); > + > + if (status == SESSION_BACKUP_RUNNING) > + ereport(ERROR, > + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), > + errmsg("a backup is already in progress in this session"))); > > I think we can move it to the beginning of SendBaseBackup() so we can > avoid bbsink initialization and cleanup in the error case. Sounds good idea to me. I updated the patch in that way. Attached. Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION --------------avCMetnnSAkqo3zkCP7pEppT Content-Type: text/plain; charset=UTF-8; name="fix_assertion_failure_and_segv_when_backup_v2.patch" Content-Disposition: attachment; filename="fix_assertion_failure_and_segv_when_backup_v2.patch" Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL3NyYy9iYWNrZW5kL2FjY2Vzcy90cmFuc2FtL3hsb2cuYyBiL3NyYy9i YWNrZW5kL2FjY2Vzcy90cmFuc2FtL3hsb2cuYwppbmRleCA4NzY0MDg0ZTIxLi5jNGQ5NTZi OWMxIDEwMDY0NAotLS0gYS9zcmMvYmFja2VuZC9hY2Nlc3MvdHJhbnNhbS94bG9nLmMKKysr IGIvc3JjL2JhY2tlbmQvYWNjZXNzL3RyYW5zYW0veGxvZy5jCkBAIC04NzgzLDYgKzg3ODMs OCBAQCBkb19wZ19hYm9ydF9iYWNrdXAoaW50IGNvZGUsIERhdHVtIGFyZykKIAl7CiAJCVhM b2dDdGwtPkluc2VydC5mb3JjZVBh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