Re: BUG #16871: Insert with wrong key field, causing later crash of DB. - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #16871: Insert with wrong key field, causing later crash of DB.
Date
Msg-id 2537460.1613577724@sss.pgh.pa.us
Whole thread Raw
In response to BUG #16871: Insert with wrong key field, causing later crash of DB.  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> 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



pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #16870: ADD COLUMN IF NOT EXISTS with GENERATED ALWAYS AS IDENTITY can cause duplicate sequence
Next
From: "Euler Taveira"
Date:
Subject: Re: BUG #16868: Cannot find sqlstat error codes.