Thread: UPDATE with json_populate_recordset empty array crashes server
Hi,
The following sequence of commands causes a reproducible backend crash:
$ createdb test
$ psql test
test=# CREATE TABLE test (foo text);
test=# WITH json_cte AS (SELECT * FROM json_populate_recordset(null::test, '[]'))
test-# UPDATE test
test-# SET foo = json_cte.foo
test-# FROM json_cte;
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
Here's the postgres output:
wrote crash dump to file "crashdumps\postgres-pid14356-221788734.mdmp"
2019-07-31 10:45:17.989 CEST [1744] LOG: server process (PID 14356) was terminated by exception 0xC0000005
2019-07-31 10:45:17.989 CEST [1744] DETAIL: Failed process was running: WITH json_cte AS (SELECT * FROM json_populate_recordset(null::test, '[]'))
UPDATE test
SET foo = json_cte.foo
FROM json_cte;
2019-07-31 10:45:17.989 CEST [1744] HINT: See C include file "ntstatus.h" for a description of the hexadecimal value.
2019-07-31 10:45:17.990 CEST [1744] LOG: terminating any other active server processes
2019-07-31 10:45:18.016 CEST [18716] WARNING: terminating connection because of crash of another server process
2019-07-31 10:45:18.016 CEST [18716] DETAIL: The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2019-07-31 10:45:18.016 CEST [18716] HINT: In a moment you should be able to reconnect to the database and repeat your command.
2019-07-31 10:45:18.073 CEST [1744] LOG: all server processes terminated; reinitializing
2019-07-31 10:45:18.174 CEST [4436] FATAL: the database system is in recovery mode
2019-07-31 10:45:18.177 CEST [1724] LOG: database system was interrupted; last known up at 2019-07-31 10:39:13 CEST
2019-07-31 10:45:30.266 CEST [1724] LOG: database system was not properly shut down; automatic recovery in progress
2019-07-31 10:45:30.303 CEST [1724] LOG: redo starts at 0/B4F00530
2019-07-31 10:45:30.303 CEST [1724] LOG: invalid record length at 0/B4F00568: wanted 24, got 0
2019-07-31 10:45:30.307 CEST [1724] LOG: redo done at 0/B4F00530
2019-07-31 10:45:30.501 CEST [1744] LOG: database system is ready to accept connections
VERSION(): PostgreSQL 11.1, compiled by Visual C++ build 1914, 64-bit
Running on Windows 10.0.17134.885
Crash dump is attached.
All the best,
Marks
Attachment
Hello > VERSION(): PostgreSQL 11.1, compiled by Visual C++ build 1914, 64-bit Please check in actual release. I think this was already fixed for a long time: https://www.postgresql.org/docs/11/release-11-2.html > Fix crash when zero rows are fed to json[b]_populate_recordset() or json[b]_to_recordset() (Tom Lane) regards, Sergei
On Wed, Jul 31, 2019 at 12:54:10PM +0300, Sergei Kornilov wrote: > I think this was already fixed for a long time: > https://www.postgresql.org/docs/11/release-11-2.html > Fix crash when zero rows are fed to json[b]_populate_recordset() > or json[b]_to_recordset() (Tom Lane) Yes, this has been fixed and it matches to this commit: commit: eba2ce17121f198316d050e71d8bd049a43783ba author: Tom Lane <tgl@sss.pgh.pa.us> date: Thu, 22 Nov 2018 15:14:01 -0500 Fix another crash in json{b}_populate_recordset and json{b}_to_recordset. And here is the related thread: https://www.postgresql.org/message-id/15514-59d5b4c4065b178b@postgresql.org -- Michael