Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hrpW3-0008D0-IL for pgsql-bugs@arkaria.postgresql.org; Sun, 28 Jul 2019 20:11:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hrpW1-0005kW-MD for pgsql-bugs@arkaria.postgresql.org; Sun, 28 Jul 2019 20:11:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hrpW1-0005hn-9h for pgsql-bugs@lists.postgresql.org; Sun, 28 Jul 2019 20:11:33 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1hrpVt-0001hD-Rh for pgsql-bugs@lists.postgresql.org; Sun, 28 Jul 2019 20:11:31 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x6SKBLkp020812; Sun, 28 Jul 2019 16:11:21 -0400 From: Tom Lane To: yi huang cc: pgsql-bugs@lists.postgresql.org, Andres Freund Subject: Re: PostgreSQL12 crash bug report In-reply-to: References: Comments: In-reply-to yi huang message dated "Mon, 29 Jul 2019 02:56:21 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <20810.1564344681.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 28 Jul 2019 16:11:21 -0400 Message-ID: <20811.1564344681@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk yi huang writes: > [ crashes with ] > $ pgbench -h 127.0.0.1 -p 5432 -U exchange exchange -T 2 -c 4 -f /tmp/te= st.sql Thanks for the report! Note that this doesn't fail if you just run test.sql by itself, but it does soon fall over as described when running multiple copies in parallel. Unsurprisingly given that, the crash is inside EvalPlanQual: (gdb) bt #0 memcpy () at ../sysdeps/x86_64/memcpy.S:526 #1 0x00000000004863b1 in fill_val (tupleDesc=3D0x18c7060, = values=3D, isnull=3D0x195e198, = data=3D, data_size=3D148670068, = infomask=3D, bit=3D0x7f07aef4207f "\017") at heaptuple.c:247 #2 heap_fill_tuple (tupleDesc=3D0x18c7060, values=3D= , = isnull=3D0x195e198, data=3D, data_size=3D14867006= 8, = infomask=3D, bit=3D0x7f07aef4207f "\017") at heaptuple.c:336 #3 0x0000000000486921 in heap_form_tuple (tupleDescriptor=3D0x18c7060, = values=3D0x7ffc691d58b0, isnull=3D0x195e198) at heaptuple.c:1090 #4 0x00000000004ddf78 in toast_build_flattened_tuple (tupleDesc=3D0x18c70= 60, = values=3D, isnull=3D0x195e198) at tuptoaster.c:13= 36 #5 0x00000000006441f0 in ExecEvalWholeRowVar (state=3D, = op=3D0x1958030, econtext=3D) at execExprInterp.c:= 4019 #6 0x0000000000647602 in ExecInterpExpr (state=3D0x1957ea0, econtext=3D0x= 19576a0, = isnull=3D0x7ffc691d8dff) at execExprInterp.c:519 #7 0x00000000006543ef in ExecEvalExprSwitchContext ( node=3D, accessMtd=3D0x67a140 , = recheckMtd=3D0x679f00 ) at ../../../src/include/executor/executor.h:307 #8 ExecProject (node=3D, accessMtd=3D0x67a140 , = recheckMtd=3D0x679f00 ) at ../../../src/include/executor/executor.h:341 #9 ExecScan (node=3D, accessMtd=3D0x67a140 , = recheckMtd=3D0x679f00 ) at execScan.c:199 #10 0x00000000006698dc in ExecProcNode (node=3D0x19573d8) at ../../../src/include/executor/executor.h:239 #11 MultiExecPrivateHash (node=3D0x19573d8) at nodeHash.c:164 #12 MultiExecHash (node=3D0x19573d8) at nodeHash.c:114 #13 0x000000000066b685 in ExecHashJoinImpl (pstate=3D0x1939d08) at nodeHashjoin.c:291 #14 ExecHashJoin (pstate=3D0x1939d08) at nodeHashjoin.c:572 #15 0x000000000064af7f in ExecProcNode (epqstate=3D) at ../../../src/include/executor/executor.h:239 #16 EvalPlanQualNext (epqstate=3D) at execMain.c:2692 #17 0x000000000064b502 in EvalPlanQual (estate=3D, = epqstate=3D0x18b5420, relation=3D, rti=3D4, = inputslot=3D0x195dfc0) at execMain.c:2475 #18 0x0000000000675f09 in ExecUpdate (mtstate=3D0x18b5328, = tupleid=3D0x7ffc691d9130, oldtuple=3D0x0, slot=3D= , = planSlot=3D0x18ca138, epqstate=3D0x18b5420, estate=3D0x18b4558, canSet= Tag=3Dtrue) at nodeModifyTable.c:1389 #19 0x000000000067668d in ExecModifyTable (pstate=3D0x18b5328) at nodeModifyTable.c:2226 #20 0x000000000064d547 in ExecProcNode (queryDesc=3D0x18b4148, = direction=3D, count=3D0, execute_once=3D40) at ../../../src/include/executor/executor.h:239 #21 ExecutePlan (queryDesc=3D0x18b4148, direction=3D,= = count=3D0, execute_once=3D40) at execMain.c:1648 #22 standard_ExecutorRun (queryDesc=3D0x18b4148, = direction=3D, count=3D0, execute_once=3D40) at execMain.c:365 #23 0x00000000007c32ab in ProcessQuery (plan=3D, = sourceText=3D0x17b7f28 "with tmp(id, avail_amount, deal_value, update_= id) as (values (76107497731002368,0.00,16546.90746,76107519298113537),(761= 07514491441155,0.606,5808.03795,76107519298113537))\nupdate t_order set av= ail_amo"..., = params=3D0x0, queryEnv=3D0x0, dest=3D, = completionTag=3D0x7ffc691d9430 "") at pquery.c:161 #24 0x00000000007c3613 in PortalRunMulti (portal=3D0x181dc48, isTopLevel=3D= true, = setHoldSnapshot=3Dfalse, dest=3D0x7f07b7f9fce0, altdest=3D0x7f07b7f9fc= e0, = completionTag=3D0x7ffc691d9430 "") at pquery.c:1283 #25 0x00000000007c3d80 in PortalRun (portal=3D0x181dc48, = count=3D9223372036854775807, isTopLevel=3Dtrue, run_once=3Dtrue, = dest=3D0x7f07b7f9fce0, altdest=3D0x7f07b7f9fce0, = completionTag=3D0x7ffc691d9430 "") at pquery.c:796 #26 0x00000000007c0001 in exec_simple_query ( ... As per the stack trace, we're trying to build a new tuple for the output of a ValuesScan node, but the targetlist for that seems completely insane: heap_form_tuple is being given a 15-column tupdesc that includes (gdb) p tupleDescriptor->attrs[1] $8 =3D {attrelid =3D 0, attname =3D {data =3D "side", '\000' }, = atttypid =3D 35644, attstattarget =3D -1, attlen =3D 4, attnum =3D 2, at= tndims =3D 0, = attcacheoff =3D 8, atttypmod =3D -1, attbyval =3D true, attstorage =3D 1= 12 'p', = attalign =3D 105 'i', attnotnull =3D false, atthasdef =3D false, = atthasmissing =3D false, attidentity =3D 0 '\000', attgenerated =3D 0 '\= 000', = attisdropped =3D false, attislocal =3D true, attinhcount =3D 0, attcolla= tion =3D 0} which seems to be the column that we have a bogus Datum for. But what's the code doing expecting that to be available from the ValueScan? It's a column of t_order. And the other data is all wrong too: that composite type should surely not have attlen =3D 4 nor attbyval =3D true. "explain verbose" claims that the Values node should be returning -> Values Scan on "*VALUES*" (cost=3D0.00..0.03 rows=3D2 = width=3D184) Output: "*VALUES*".column2, "*VALUES*".column3, "*VAL= UES*".column4, "*VALUES*".*, "*VALUES*".column1 so it seems like somehow we've got wrong info in the EPQ context. I wonder if this is related to the "Hash join explain is broken" thread. regards, tom lane