REL_12_STABLE crashing with assertion failure in ExtractReplicaIdentity

From: Hadi Moshayedi <hadi(at)moshayedi(dot)net>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: REL_12_STABLE crashing with assertion failure in ExtractReplicaIdentity
Date: 2019-08-16 16:44:15
Message-ID: CAK=1=Wrek44Ese1V7LjKiQS-Nd-5LgLi_5_CskGbpggKEf3tKQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

It seems that sometimes when DELETE cascades to referencing tables we fail
to acquire locks on replica identity index.

To reproduce, set wal_level to logical, and run 1.sql.

I can look into this, but I thought first I should send it here in case
someone who is more familiar with these related functions can solve it
quickly.

I get the following backtrace:

#0 __GI_raise (sig=sig(at)entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1 0x00007f301154b801 in __GI_abort () at abort.c:79
#2 0x000055df8858a923 in ExceptionalCondition (
conditionName=conditionName(at)entry=0x55df885fd138
"!(CheckRelationLockedByMe(idx_rel, 1, 1))",
errorType=errorType(at)entry=0x55df885de8fd
"FailedAssertion",
fileName=fileName(at)entry=0x55df885fca32 "heapam.c",
lineNumber=lineNumber(at)entry=7646)
at assert.c:54
#3 0x000055df88165e53 in ExtractReplicaIdentity
(relation=relation(at)entry=0x7f3012b54db0,

tp=tp(at)entry=0x7ffcf47d53f0, key_changed=key_changed(at)entry=true,
copy=copy(at)entry=0x7ffcf47d53d3) at heapam.c:7646
#4 0x000055df8816c22b in heap_delete (relation=0x7f3012b54db0,
tid=<optimized out>,
cid=<optimized out>, crosscheck=0x0, wait=true, tmfd=0x7ffcf47d54b0,
changingPart=false)
at heapam.c:2676
#5 0x000055df88318b62 in table_tuple_delete (changingPart=false,
tmfd=0x7ffcf47d54b0,
wait=true, crosscheck=<optimized out>, snapshot=<optimized out>,
cid=<optimized out>,
tid=0x7ffcf47d558a, rel=0x7f3012b54db0) at
../../../src/include/access/tableam.h:1216
#6 ExecDelete (mtstate=mtstate(at)entry=0x55df8a8196a0,
tupleid=0x7ffcf47d558a, oldtuple=0x0,
planSlot=planSlot(at)entry=0x55df8a81a8e8,
epqstate=epqstate(at)entry=0x55df8a819798,

estate=estate(at)entry=0x55df8a819058, processReturning=true,
canSetTag=true,
changingPart=false, tupleDeleted=0x0, epqreturnslot=0x0) at
nodeModifyTable.c:769
#7 0x000055df8831aa25 in ExecModifyTable (pstate=0x55df8a8196a0) at
nodeModifyTable.c:2230
#8 0x000055df882efa9a in ExecProcNode (node=0x55df8a8196a0)
at ../../../src/include/executor/executor.h:239
#9 ExecutePlan (execute_once=<optimized out>, dest=0x55df88a89a00
<spi_printtupDR>,
direction=<optimized out>, numberTuples=0, sendTuples=<optimized out>,
operation=CMD_DELETE, use_parallel_mode=<optimized out>,
planstate=0x55df8a8196a0,
estate=0x55df8a819058) at execMain.c:1648
#10 standard_ExecutorRun (queryDesc=0x55df8a7de4b0, direction=<optimized
out>, count=0,
execute_once=<optimized out>) at execMain.c:365
#11 0x000055df8832b90c in _SPI_pquery (tcount=0, fire_triggers=false,
queryDesc=0x55df8a7de4b0) at spi.c:2521
#12 _SPI_execute_plan (plan=plan(at)entry=0x55df8a812828, paramLI=<optimized
out>,
snapshot=snapshot(at)entry=0x0,
crosscheck_snapshot=crosscheck_snapshot(at)entry=0x0,
read_only=read_only(at)entry=false, fire_triggers=fire_triggers(at)entry=false,

tcount=<optimized out>) at spi.c:2296
#13 0x000055df8832c15c in SPI_execute_snapshot (plan=plan(at)entry=0x55df8a812828,

Values=Values(at)entry=0x7ffcf47d5820, Nulls=Nulls(at)entry=0x7ffcf47d5a20 "
",
snapshot=snapshot(at)entry=0x0,
crosscheck_snapshot=crosscheck_snapshot(at)entry=0x0,
read_only=read_only(at)entry=false, fire_triggers=false, tcount=0) at
spi.c:616
#14 0x000055df88522f32 in ri_PerformCheck (riinfo=riinfo(at)entry=0x55df8a7f8050,

qkey=qkey(at)entry=0x7ffcf47d5b28, qplan=0x55df8a812828,
fk_rel=fk_rel(at)entry=0x7f3012b54db0, pk_rel=pk_rel(at)entry=0x7f3012b44a28,
oldslot=oldslot(at)entry=0x55df8a826f88, newslot=0x0, detectNewRows=true,
expect_OK=8)
at ri_triggers.c:2276
#15 0x000055df88524653 in RI_FKey_cascade_del (fcinfo=<optimized out>) at
ri_triggers.c:819
#16 0x000055df882c9996 in ExecCallTriggerFunc
(trigdata=trigdata(at)entry=0x7ffcf47d5ff0,

tgindx=tgindx(at)entry=0, finfo=finfo(at)entry=0x55df8a825710,
instr=instr(at)entry=0x0,
per_tuple_context=per_tuple_context(at)entry=0x55df8a812f10) at
trigger.c:2432
#17 0x000055df882cb459 in AfterTriggerExecute (trigdesc=0x55df8a825530,
trigdesc=0x55df8a825530, trig_tuple_slot2=0x0, trig_tuple_slot1=0x0,
per_tuple_context=0x55df8a812f10, instr=0x0, finfo=0x55df8a825710,
relInfo=0x55df8a825418, event=0x55df8a81f0a8, estate=0x55df8a825188) at
trigger.c:4342
#18 afterTriggerInvokeEvents (events=events(at)entry=0x55df8a7c3e40,
firing_id=1,
estate=estate(at)entry=0x55df8a825188, delete_ok=delete_ok(at)entry=false) at
trigger.c:4539
#19 0x000055df882d1408 in AfterTriggerEndQuery (estate=estate(at)entry
=0x55df8a825188)
at trigger.c:4850
#20 0x000055df882efd99 in standard_ExecutorFinish (queryDesc=0x55df8a722ab8)
at execMain.c:440
#21 0x000055df88464bdd in ProcessQuery (plan=<optimized out>,
sourceText=0x55df8a702f78 "DELETE FROM t1 RETURNING id;", params=0x0,
queryEnv=0x0,
dest=0x55df8a722a20, completionTag=0x7ffcf47d6180 "DELETE 11") at
pquery.c:203
#22 0x000055df88464e0b in PortalRunMulti (portal=portal(at)entry=0x55df8a7692f8,

isTopLevel=isTopLevel(at)entry=true,
setHoldSnapshot=setHoldSnapshot(at)entry=true,

dest=dest(at)entry=0x55df8a722a20, altdest=0x55df88a81040 <donothingDR>,
completionTag=completionTag(at)entry=0x7ffcf47d6180 "DELETE 11") at
pquery.c:1283
#23 0x000055df88465119 in FillPortalStore (portal=portal(at)entry=0x55df8a7692f8,

isTopLevel=isTopLevel(at)entry=true) at pquery.c:1030
#24 0x000055df88465d1d in PortalRun (portal=portal(at)entry=0x55df8a7692f8,
count=count(at)entry=9223372036854775807, isTopLevel=isTopLevel(at)entry=true,

run_once=run_once(at)entry=true, dest=dest(at)entry=0x55df8a7ddb08,
altdest=altdest(at)entry=0x55df8a7ddb08, completionTag=0x7ffcf47d63b0 "")
at pquery.c:765
#25 0x000055df88461512 in exec_simple_query (
query_string=0x55df8a702f78 "DELETE FROM t1 RETURNING id;") at
postgres.c:1215
#26 0x000055df8846344e in PostgresMain (argc=<optimized out>,
argv=argv(at)entry=0x55df8a72d4b0, dbname=<optimized out>,
username=<optimized out>)
at postgres.c:4236
#27 0x000055df8811906d in BackendRun (port=0x55df8a7234d0,
port=0x55df8a7234d0)
at postmaster.c:4431
#28 BackendStartup (port=0x55df8a7234d0) at postmaster.c:4122
#29 ServerLoop () at postmaster.c:1704
#30 0x000055df883dc53e in PostmasterMain (argc=3, argv=0x55df8a6fb7c0) at
postmaster.c:1377
#31 0x000055df8811ad5f in main (argc=3, argv=0x55df8a6fb7c0) at main.c:228

Attachment Content-Type Size
1.sql application/sql 696 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2019-08-16 17:17:45 Re: Global temporary tables
Previous Message Anastasia Lubennikova 2019-08-16 15:56:12 Re: [HACKERS] [WIP] Effective storage of duplicates in B-tree index.