Re: TRAP: FailedAssertion("HaveRegisteredOrActiveSnapshot()", File: "toast_internals.c", Line: 670, PID: 19403) - Mailing list pgsql-hackers

From Kyotaro Horiguchi
Subject Re: TRAP: FailedAssertion("HaveRegisteredOrActiveSnapshot()", File: "toast_internals.c", Line: 670, PID: 19403)
Date
Msg-id 20220328.183646.1041002117568499041.horikyota.ntt@gmail.com
Whole thread Raw
In response to TRAP: FailedAssertion("HaveRegisteredOrActiveSnapshot()", File: "toast_internals.c", Line: 670, PID: 19403)  (Erik Rijkers <er@xs4all.nl>)
Responses Re: TRAP: FailedAssertion("HaveRegisteredOrActiveSnapshot()", File: "toast_internals.c", Line: 670, PID: 19403)  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
List pgsql-hackers
At Sun, 27 Mar 2022 20:32:45 +0200, Erik Rijkers <er@xs4all.nl> wrote in 
> On master I got a FailedAssertion("HaveRegisteredOrActiveSnapshot()"
> on an assert-enabled instance and with (I think) data over a certain
> length.
> 
> I whittled it down to the attached bash (careful - it drops stuff).
> It has 5 tsv-data lines (one long line) that COPY slurps into a table.
> The middle, third line causes the problem, later on.  Shortening the
> long line to somewhere below 2000 characters fixes it again.
> 
> More info in the attached .sh file.

It is reproducible for me. Thanks for the reproducer.

> If debug-assert is 'off', the problem does not occur. (REL_14_STABLE
> also does not have the problem, assertions or not)

It seems like related with [1]?

Inserting EnsurePortalSnapshotExists() to RunFromStore fixes this but
I'm not sure where is the right place to do this..

[1] https://www.postgresql.org/message-id/flat/20210623035916.GL29179%40telsasoft.com#f802617a00cee4d013ad8fa69e1af048

For someone's information, this is more readable stack trace.

#0  0x00007f43aeed037f in raise () from /lib64/libc.so.6
#1  0x00007f43aeebadb5 in abort () from /lib64/libc.so.6
#2  0x0000000000b28747 in ExceptionalCondition (
    conditionName=0xba2c48 "HaveRegisteredOrActiveSnapshot()", 
    errorType=0xba2882 "FailedAssertion", 
    fileName=0xba2870 "toast_internals.c", lineNumber=670) at assert.c:69
#3  0x00000000004ac776 in init_toast_snapshot (toast_snapshot=0x7ffce64f7440)
    at toast_internals.c:670
#4  0x00000000005164ea in heap_fetch_toast_slice (toastrel=0x7f43b193cad0, 
    valueid=16393, attrsize=1848, sliceoffset=0, slicelength=1848, 
    result=0x1cbb948) at heaptoast.c:688
#5  0x000000000049fc86 in table_relation_fetch_toast_slice (
    toastrel=0x7f43b193cad0, valueid=16393, attrsize=1848, sliceoffset=0, 
    slicelength=1848, result=0x1cbb948)
    at ../../../../src/include/access/tableam.h:1892
#6  0x00000000004a0a0f in toast_fetch_datum (attr=0x1d6b171) at detoast.c:375
#7  0x000000000049fffb in detoast_attr (attr=0x1d6b171) at detoast.c:123
#8  0x0000000000b345ba in pg_detoast_datum_packed (datum=0x1d6b171)
    at fmgr.c:1757
#9  0x0000000000aece72 in text_to_cstring (t=0x1d6b171) at varlena.c:225
#10 0x0000000000aedda2 in textout (fcinfo=0x7ffce64f77a0) at varlena.c:574
#11 0x0000000000b331bf in FunctionCall1Coll (flinfo=0x1d695e0, collation=0, 
    arg1=30847345) at fmgr.c:1138
#12 0x0000000000b3422b in OutputFunctionCall (flinfo=0x1d695e0, val=30847345)
    at fmgr.c:1575
#13 0x00000000004a6b6c in printtup (slot=0x1cb81f0, self=0x1c96e90)
    at printtup.c:357
#14 0x000000000099499f in RunFromStore (portal=0x1cf9380, 
    direction=ForwardScanDirection, count=0, dest=0x1c96e90) at pquery.c:1096
#15 0x00000000009944e3 in PortalRunSelect (portal=0x1cf9380, forward=true, 
    count=0, dest=0x1c96e90) at pquery.c:917
#16 0x00000000009941d3 in PortalRun (portal=0x1cf9380, 
    count=9223372036854775807, isTopLevel=true, run_once=true, 
    dest=0x1c96e90, altdest=0x1c96e90, qc=0x7ffce64f7ac0) at pquery.c:765
#17 0x000000000098df4b in exec_simple_query (
    query_string=0x1c96030 "fetch all in myportal;") at postgres.c:1250
#18 0x00000000009923a3 in PostgresMain (dbname=0x1cc11b0 "postgres", 
    username=0x1cc1188 "horiguti") at postgres.c:4520
#19 0x00000000008c6caf in BackendRun (port=0x1cb74c0) at postmaster.c:4593
#20 0x00000000008c6631 in BackendStartup (port=0x1cb74c0) at postmaster.c:4321
#21 0x00000000008c29cb in ServerLoop () at postmaster.c:1801
#22 0x00000000008c2298 in PostmasterMain (argc=1, argv=0x1c8e0e0)
    at postmaster.c:1473
#23 0x00000000007c14c3 in main (argc=1, argv=0x1c8e0e0) at main.c:202



regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center



pgsql-hackers by date:

Previous
From: Jelte Fennema
Date:
Subject: Re: [EXTERNAL] Re: Add non-blocking version of PQcancel
Next
From: Jian Guo
Date:
Subject: Re: Summary Sort workers Stats in EXPLAIN ANALYZE