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 1lCPHL-0004Nr-6V for pgsql-bugs@arkaria.postgresql.org; Wed, 17 Feb 2021 16:02:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lCPHK-0003WW-4A for pgsql-bugs@arkaria.postgresql.org; Wed, 17 Feb 2021 16:02:14 +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 1lCPHJ-0003WP-U8 for pgsql-bugs@lists.postgresql.org; Wed, 17 Feb 2021 16:02:13 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lCPHD-0005H3-Gk for pgsql-bugs@lists.postgresql.org; Wed, 17 Feb 2021 16:02:13 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 11HG24it2537461; Wed, 17 Feb 2021 11:02:04 -0500 From: Tom Lane To: david@littleriver.ca cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16871: Insert with wrong key field, causing later crash of DB. In-reply-to: <16871-aeb175c060566417@postgresql.org> References: <16871-aeb175c060566417@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Wed, 17 Feb 2021 11:24:53 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2537459.1613577724.1@sss.pgh.pa.us> Date: Wed, 17 Feb 2021 11:02:04 -0500 Message-ID: <2537460.1613577724@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Bug reporting form writes: > This has happened three times to me over the last few months. Database > crashes later on insert with faulty char[32] key field, matthew vs proper > key of matt. > 2021-02-17 00:25:29 AST ERROR: insert or update on table "employee_shift" > violates foreign key constraint "employee_shift_userid_fkey" > 2021-02-17 00:25:29 AST DETAIL: Key (userid)=(matthew > ) is not present in table "users". > 2021-02-17 00:25:29 AST STATEMENT: INSERT INTO batch.employee_shift > (userid, date, shift,milking_number) VALUES ('matthew', '2019-09-14', > 'am',1); > 2021-02-17 06:23:09 AST LOG: received fast shutdown request > 2021-02-17 06:23:09 AST LOG: aborting any active transactions Well, that's not a crash; that's a commanded shutdown. (The *only* way to get that message is for something to send the postmaster a SIGINT signal.) It's fairly hard to credit that there's any direct connection to a simple SQL error six hours earlier, either. I'm going to venture out on a limb here, but I'd suggest reviewing exactly how you're starting Postgres. If you're launching it from a manual shell command, and you're not being careful to fully dissociate it from the shell's terminal, then you can get results like this when you later type control-C, log out from that session, etc. regards, tom lane