Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gEm0g-0000aU-TP for pgsql-bugs@arkaria.postgresql.org; Tue, 23 Oct 2018 02:01:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gEm0e-0006yM-Fm for pgsql-bugs@arkaria.postgresql.org; Tue, 23 Oct 2018 02:01:28 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gEm0e-0006yF-6B for pgsql-bugs@lists.postgresql.org; Tue, 23 Oct 2018 02:01:28 +0000 Received: from tama50.ecl.ntt.co.jp ([129.60.39.147]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gEm0W-0000V0-FJ; Tue, 23 Oct 2018 02:01:26 +0000 Received: from vc2.ecl.ntt.co.jp (vc2.ecl.ntt.co.jp [129.60.86.154]) by tama50.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id w9N21FdU022473; Tue, 23 Oct 2018 11:01:15 +0900 Received: from vc2.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id D78AE638228; Tue, 23 Oct 2018 11:01:15 +0900 (JST) Received: from jcms-pop21.ecl.ntt.co.jp (jcms-pop21.ecl.ntt.co.jp [129.60.87.134]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id C19E463831C; Tue, 23 Oct 2018 11:01:15 +0900 (JST) Received: from [127.0.0.1] (unknown [129.60.241.61]) by jcms-pop21.ecl.ntt.co.jp (Postfix) with ESMTPSA id BA82140078E; Tue, 23 Oct 2018 11:01:15 +0900 (JST) Subject: Re: BUG #15448: server process (PID 22656) was terminated by exception 0xC0000005 References: <15448-068ca37e168742d6@postgresql.org> From: Amit Langote Message-ID: <9cb4aa1c-12ba-59c3-fd75-545fa90fb92f@lab.ntt.co.jp> Date: Tue, 23 Oct 2018 11:00:56 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <15448-068ca37e168742d6@postgresql.org> Content-Type: multipart/mixed; boundary="------------941228A624819E0D18F22068" Content-Language: en-US X-CC-Mail-RelayStamp: 1 To: tillmann73@yahoo.de, pgsql-bugs@lists.postgresql.org, PG Bug reporting form Cc: andrew.dunstan@2ndquadrant.com X-TM-AS-MML: disable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------941228A624819E0D18F22068 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Hi, On 2018/10/22 21:34, PG Bug reporting form wrote: > The following bug has been logged on the website: > > Bug reference: 15448 > Logged by: Tillmann Schulz > Email address: tillmann73@yahoo.de > PostgreSQL version: 11.0 > Operating system: Windows > Description: > > I have a reproducable error when running two junit test cases in sequence > from Java with Postgres 11.0.1. With postgres 10 everything worked fine. > > > The error occurs at > > 2018-10-22 14:06:59.651 CEST [22696] LOG: server process (PID 22656) was > terminated by exception 0xC0000005 > 2018-10-22 14:06:59.651 CEST [22696] DETAIL: Failed process was running: > delete from c5_member Thanks for the report and the log. (Today I learned that exception 0xC0000005 is the Windows equivalent of "segmentation fault".) > Aft that, postgres is in recovery mode. Shortly after that the database is > availiably again. > > The complete log of both testcases is: After observing the test case in the provided log, I managed to reproduce it with the following: create table foo (a int primary key, b int); create table bar (a int references foo on delete cascade, b int); insert into foo values (1, 1); insert into foo values (2, 2); alter table foo add c int; alter table foo drop c; delete from foo; server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. The connection to the server was lost. Attempting reset: Failed. Analyzing this crash, I located the bug down to GetTupleForTrigger(), but perhaps it's really in heap_expand_tuple() / expand_tuple(), where the value of trigger tuple's t_self is being switched from a valid one to an invalid value. In heaptuple.c: expand_tuple() ItemPointerSetInvalid(&((*targetHeapTuple)->t_self)); FWIW, attached patch fixes this for me. Adding Andrew whose recent commit 7636e5c60f [1] seems to have introduced the heap_expan_tuple call in GetTupleForTrigger. Maybe, he can better judge a fix for this. Thanks, Amit [1] https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=7636e5c60f --------------941228A624819E0D18F22068 Content-Type: text/plain; charset=UTF-8; name="GetTupleForTrigger-fix.patch" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="GetTupleForTrigger-fix.patch" ZGlmZiAtLWdpdCBhL3NyYy9iYWNrZW5kL2NvbW1hbmRzL3RyaWdnZXIuYyBiL3NyYy9iYWNr ZW5kL2NvbW1hbmRzL3RyaWdnZXIuYwppbmRleCAyNDBlODVlMzkxLi4zYzljZTliZTBjIDEw MDY0NAotLS0gYS9zcmMvYmFja2VuZC9jb21tYW5kcy90cmlnZ2VyLmMKKysrIGIvc3JjL2Jh Y2tlbmQvY29tbWFuZHMvdHJpZ2dlci5jCkBAIC0zMzk5LDcgKzMzOTksMTAgQEAgbHRybWFy azo7CiAJfQogCiAJaWYgKEhlYXBUdXBsZUhlYWRlckdldE5hdHRzKHR1cGxlLnRfZGF0YSkg PCByZWxhdGlvbi0+cmRfYXR0LT5uYXR0cykKKwl7CiAJCXJlc3VsdCA9IGhlYXBfZXhwYW5k X3R1cGxlKCZ0dXBsZSwgcmVsYXRpb24tPnJkX2F0dCk7CisJCXJlc3VsdC0+dF9zZWxmID0g KnRpZDsKKwl9CiAJZWxzZQogCQlyZXN1bHQgPSBoZWFwX2NvcHl0dXBsZSgmdHVwbGUpOwog CVJlbGVhc2VCdWZmZXIoYnVmZmVyKTsK --------------941228A624819E0D18F22068--