| From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Cc: | 303677365(at)qq(dot)com |
| Subject: | BUG #19427: TOAST Snapshot Assertion Failure |
| Date: | 2026-03-11 09:21:57 |
| Message-ID: | 19427-44560ddf098e6489@postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 19427
Logged by: chunling qin
Email address: 303677365(at)qq(dot)com
PostgreSQL version: 15.0
Operating system: centos
Description:
## Description
PostgreSQL crashes with an assertion failure when executing UPDATE
statements with RETURNING clause that returns TOAST-compressed data
(specifically `pg_node_tree` type from system catalogs). The assertion
`HaveRegisteredOrActiveSnapshot()` fails in `init_toast_snapshot()`
function.
## Crash Information
### Signal
```
SIGABRT (Assertion failure)
```
### Stack Trace
```
#0 __pthread_kill_implementation () from /lib64/libc.so.6
#1 raise () from /lib64/libc.so.6
#2 abort () from /lib64/libc.so.6
#3 ExceptionalCondition (conditionName="HaveRegisteredOrActiveSnapshot()",
errorType="FailedAssertion",
fileName="toast_internals.c", lineNumber=670)
#4 init_toast_snapshot (toast_snapshot=0x7ffd01b64e50) at
toast_internals.c:670
#5 heap_fetch_toast_slice (toastrel=..., valueid=12032, attrsize=2448,
sliceoffset=0, slicelength=2448, result=...)
at heaptoast.c:688
#6 table_relation_fetch_toast_slice (...) at tableam.h:1892
#7 toast_fetch_datum (attr=...) at detoast.c:375
#8 detoast_attr (attr=...) at detoast.c:123
#9 pg_detoast_datum_packed (datum=...) at fmgr.c:1757
#10 text_to_cstring (t=...) at varlena.c:225
#11 textout (fcinfo=...) at varlena.c:574
#12 pg_node_tree_out (fcinfo=...) at pseudotypes.c:354
#13 FunctionCall1Coll (...) at fmgr.c:1138
#14 OutputFunctionCall (...) at fmgr.c:1575
#15 printtup (...) at printtup.c:357
```
## Reproduction
### Minimal Test Case
```sql
-- Case 1: UPDATE system catalog with RETURNING TOAST column
UPDATE pg_catalog.pg_rewrite SET rulename = rulename
WHERE oid = (SELECT oid FROM pg_catalog.pg_rewrite LIMIT 1)
RETURNING ev_action;
-- Case 2: UPDATE with subquery returning TOAST data
CREATE TABLE test_table (id int, col_varchar varchar);
INSERT INTO test_table VALUES (1, 'test');
UPDATE test_table SET id = id
RETURN
id,
(SELECT ev_action FROM pg_catalog.pg_rewrite LIMIT 1) AS ev_action;
```
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Heikki Linnakangas | 2026-03-11 16:00:42 | Re: BUG #19427: TOAST Snapshot Assertion Failure |
| Previous Message | Etsuro Fujita | 2026-03-11 08:01:02 | Re: Re: FDW connection drops with "Connection timed out" during async append query due to TCP receive buffer filling up |