pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #15828: Server crashes inside CloneRowTriggersToPartition
3+ messages / 3 participants
[nested] [flat]

Commits from this thread:
  2019-06-03 601084eb1a eaf0292c3b  Fix unsafe memory management in CloneRowTriggersToPartition().
* BUG #15828: Server crashes inside CloneRowTriggersToPartition
@ 2019-05-31 18:50 PG Bug reporting form <noreply@postgresql.org>
  2019-05-31 19:01 ` Re: BUG #15828: Server crashes inside CloneRowTriggersToPartition Alexander Lakhin <exclusion@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: PG Bug reporting form @ 2019-05-31 18:50 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: exclusion@gmail.com

The following bug has been logged on the website:

Bug reference:      15828
Logged by:          Alexander Lakhin
Email address:      exclusion@gmail.com
PostgreSQL version: 12beta1
Operating system:   Ubuntu 18.04
Description:        

When running in parallel two queries (modified excerpts from
src/test/regress/ join.sql and update.sql):
--
SELECT count(*) FROM
  tenk1 a JOIN tenk1 b ON a.unique1 = b.unique2
  LEFT JOIN tenk1 c ON c.thousand = a.thousand;
--
DROP TABLE IF EXISTS range_parted CASCADE;
DROP FUNCTION IF EXISTS trigfunc CASCADE;

CREATE TABLE range_parted (b bigint) PARTITION BY RANGE (b);
CREATE TABLE part_1_10 PARTITION OF range_parted FOR VALUES FROM (1) TO
(10);

CREATE FUNCTION trigfunc() RETURNS TRIGGER LANGUAGE plpgsql AS 'begin return
null; end;';

CREATE TRIGGER trigger1  AFTER INSERT ON range_parted FOR EACH STATEMENT
EXECUTE PROCEDURE trigfunc();

CREATE TRIGGER trigger2  AFTER INSERT ON range_parted FOR EACH STATEMENT
EXECUTE PROCEDURE trigfunc();
DROP TRIGGER trigger2 ON range_parted;

INSERT INTO range_parted VALUES (0);
SELECT pg_sleep(0.05);
CREATE TABLE part_def PARTITION OF range_parted DEFAULT;
--
I get a crash with the following core dump:

Core was generated by `postgres: law regression [local] CREATE TABLE        
                        '.
Program terminated with signal SIGBUS, Bus error.
#0  0x000055594492427f in GetMemoryChunkContext (pointer=0x5559466ff0a0)
    at ../../../../src/include/utils/memutils.h:129
129             AssertArg(MemoryContextIsValid(context));
(gdb) bt
#0  0x000055594492427f in GetMemoryChunkContext (pointer=0x5559466ff0a0)
    at ../../../../src/include/utils/memutils.h:129
#1  pfree (pointer=0x5559466ff0a0) at mcxt.c:1033
#2  0x00005559444dedc4 in btendscan (scan=<optimized out>) at nbtree.c:479
#3  0x00005559444d2eaf in index_endscan (scan=0x5559466fc9f0) at
indexam.c:328
#4  0x00005559444d25ed in systable_endscan
(sysscan=sysscan@entry=0x55594663ccc0) at genam.c:535
#5  0x0000555944604716 in CloneRowTriggersToPartition
(parent=parent@entry=0x7fcb7cbb97b8, 
    partition=partition@entry=0x7fcb7cbbd138) at tablecmds.c:15885
#6  0x00005559446155b4 in DefineRelation (stmt=stmt@entry=0x5559466e1050,
relkind=<optimized out>, 
    relkind@entry=114 'r', ownerId=10, ownerId@entry=0,
typaddress=typaddress@entry=0x0, 
    queryString=queryString@entry=0x55594661c788 "CREATE TABLE part_def
PARTITION OF range_parted DEFAULT;")
    at tablecmds.c:1090
#7  0x00005559447cf575 in ProcessUtilitySlow
(pstate=pstate@entry=0x5559466e0f38, pstmt=pstmt@entry=0x55594661d718, 
    queryString=queryString@entry=0x55594661c788 "CREATE TABLE part_def
PARTITION OF range_parted DEFAULT;", 
    context=context@entry=PROCESS_UTILITY_TOPLEVEL, params=params@entry=0x0,
queryEnv=queryEnv@entry=0x0, 
    dest=0x55594661d810, completionTag=0x7ffe17b7bb00 "") at
utility.c:1014
#8  0x00005559447cf329 in standard_ProcessUtility (pstmt=0x55594661d718, 
    queryString=0x55594661c788 "CREATE TABLE part_def PARTITION OF
range_parted DEFAULT;", 
    context=PROCESS_UTILITY_TOPLEVEL, params=0x0, queryEnv=0x0,
dest=0x55594661d810, completionTag=0x7ffe17b7bb00 "")
    at utility.c:927
#9  0x00005559447cf3d7 in ProcessUtility (pstmt=pstmt@entry=0x55594661d718,
queryString=<optimized out>, 
    context=context@entry=PROCESS_UTILITY_TOPLEVEL, params=<optimized out>,
queryEnv=<optimized out>, 
    dest=dest@entry=0x55594661d810, completionTag=0x7ffe17b7bb00 "") at
utility.c:360
#10 0x00005559447cb87e in PortalRunUtility
(portal=portal@entry=0x555946683b58, pstmt=pstmt@entry=0x55594661d718, 
    isTopLevel=isTopLevel@entry=true,
setHoldSnapshot=setHoldSnapshot@entry=false, dest=dest@entry=0x55594661d810,

    completionTag=completionTag@entry=0x7ffe17b7bb00 "") at pquery.c:1175
#11 0x00005559447cc4cd in PortalRunMulti
(portal=portal@entry=0x555946683b58, isTopLevel=isTopLevel@entry=true, 
    setHoldSnapshot=setHoldSnapshot@entry=false,
dest=dest@entry=0x55594661d810, altdest=altdest@entry=0x55594661d810, 
    completionTag=completionTag@entry=0x7ffe17b7bb00 "") at pquery.c:1321
#12 0x00005559447cd23d in PortalRun (portal=portal@entry=0x555946683b58,
count=count@entry=9223372036854775807, 
    isTopLevel=isTopLevel@entry=true, run_once=run_once@entry=true,
dest=dest@entry=0x55594661d810, 
    altdest=altdest@entry=0x55594661d810, completionTag=0x7ffe17b7bb00 "")
at pquery.c:796
#13 0x00005559447c94ed in exec_simple_query (
    query_string=query_string@entry=0x55594661c788 "CREATE TABLE part_def
PARTITION OF range_parted DEFAULT;")
    at postgres.c:1215
#14 0x00005559447cb4bd in PostgresMain (argc=<optimized out>,
argv=argv@entry=0x555946647dc0, dbname=<optimized out>, 
    username=<optimized out>) at postgres.c:4249
#15 0x000055594473dcaa in BackendRun (port=port@entry=0x555946640e80) at
postmaster.c:4431
#16 0x0000555944740ece in BackendStartup (port=port@entry=0x555946640e80) at
postmaster.c:4122
#17 0x00005559447411e5 in ServerLoop () at postmaster.c:1704
#18 0x00005559447425f2 in PostmasterMain (argc=8, argv=<optimized out>) at
postmaster.c:1377
#19 0x000055594469e26e in main (argc=8, argv=0x555946616b70) at main.c:228



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #15828: Server crashes inside CloneRowTriggersToPartition
  2019-05-31 18:50 BUG #15828: Server crashes inside CloneRowTriggersToPartition PG Bug reporting form <noreply@postgresql.org>
@ 2019-05-31 19:01 ` Alexander Lakhin <exclusion@gmail.com>
  2019-06-03 20:38   ` Re: BUG #15828: Server crashes inside CloneRowTriggersToPartition Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 3+ messages in thread

From: Alexander Lakhin @ 2019-05-31 19:01 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org

> The following bug has been logged on the website:
>
> Bug reference:      15828
> Logged by:          Alexander Lakhin
> Email address:      exclusion@gmail.com
> PostgreSQL version: 12beta1
> Operating system:   Ubuntu 18.04
> Description:        
>
> When running in parallel two queries (modified excerpts from
> src/test/regress/ join.sql and update.sql):
The patch to reproduce the crash on master is attached,
With the patch applied, you can execute
'EXTRA_TESTS="--schedule=test_schedule" make check' and get:
...
test stats                        ... ok          642 ms
parallel group (2 tests):  join1 update1
     join1                        ... FAILED       43 ms
     update1                      ... FAILED (test process exited with
exit code 2)      530 ms
============== shutting down postmaster               ==============
...

Best regards,
Alexander

Attachments:

reproduce-15828.patch (text/x-patch, 1.7K) download diff --git a/src/test/regress/expected/join1.out b/src/test/regress/expected/join1.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/regress/expected/update1.out b/src/test/regress/expected/update1.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/test/regress/sql/join1.sql b/src/test/regress/sql/join1.sql new file mode 100644 index 0000000000..69efb73b2f --- /dev/null +++ b/src/test/regress/sql/join1.sql @@ -0,0 +1,3 @@ +SELECT count(*) FROM + tenk1 a JOIN tenk1 b ON a.unique1 = b.unique2 + LEFT JOIN tenk1 c ON c.thousand = a.thousand; diff --git a/src/test/regress/sql/update1.sql b/src/test/regress/sql/update1.sql new file mode 100644 index 0000000000..d9b41b0375 --- /dev/null +++ b/src/test/regress/sql/update1.sql @@ -0,0 +1,16 @@ +DROP TABLE IF EXISTS range_parted CASCADE; +DROP FUNCTION IF EXISTS trigfunc CASCADE; + +CREATE TABLE range_parted (b bigint) PARTITION BY RANGE (b); +CREATE TABLE part_1_10 PARTITION OF range_parted FOR VALUES FROM (1) TO (10); + +CREATE FUNCTION trigfunc() RETURNS TRIGGER LANGUAGE plpgsql AS 'begin return null; end;'; + +CREATE TRIGGER trigger1 AFTER INSERT ON range_parted FOR EACH STATEMENT EXECUTE PROCEDURE trigfunc(); + +CREATE TRIGGER trigger2 AFTER INSERT ON range_parted FOR EACH STATEMENT EXECUTE PROCEDURE trigfunc(); +DROP TRIGGER trigger2 ON range_parted; + +INSERT INTO range_parted VALUES (0); +SELECT pg_sleep(0.05); +CREATE TABLE part_def PARTITION OF range_parted DEFAULT; diff --git a/src/test/regress/test_schedule b/src/test/regress/test_schedule new file mode 100644 index 0000000000..04c3b29c59 --- /dev/null +++ b/src/test/regress/test_schedule @@ -0,0 +1 @@ +test: join1 update1
^ permalink raw reply [nested|flat] 3+ messages in thread

* Re: BUG #15828: Server crashes inside CloneRowTriggersToPartition
  2019-05-31 18:50 BUG #15828: Server crashes inside CloneRowTriggersToPartition PG Bug reporting form <noreply@postgresql.org>
  2019-05-31 19:01 ` Re: BUG #15828: Server crashes inside CloneRowTriggersToPartition Alexander Lakhin <exclusion@gmail.com>
@ 2019-06-03 20:38   ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2019-06-03 20:38 UTC (permalink / raw)
  To: Alexander Lakhin <exclusion@gmail.com>; +Cc: pgsql-bugs@lists.postgresql.org

Alexander Lakhin <exclusion@gmail.com> writes:
>> When running in parallel two queries (modified excerpts from
>> src/test/regress/ join.sql and update.sql):

> The patch to reproduce the crash on master is attached,

Thanks for the test case.  It's surprising though that we don't see
this fail out-of-the-box.  It's not okay to reset the context that
a systable scan is using ...

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2019-06-03 20:38 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-05-31 18:50 BUG #15828: Server crashes inside CloneRowTriggersToPartition PG Bug reporting form <noreply@postgresql.org>
2019-05-31 19:01 ` Alexander Lakhin <exclusion@gmail.com>
2019-06-03 20:38   ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox