Hello Team,
I am trying to use the PLV8 via function and while using the function
created via PLV8 in one of the create materialized view, postgres crashes,
attached is the log file with DEBUG5 turned on.
SQL which is breaking the code and SQL function is attached.
Creating materialized view - mat_view_by_product - is the one which causes
the crash.
I have tested the same in below environments
1. Test 1 - Passed
Mac , Postgres - 10.4, PLV8 - 2.1.0
2. Test 2 - Passed
AWS RDS , Postgres - 9.6.6 , PLV8 - 1.5.0
3. Test 3 - Fail, This test was passing earlier on 10.3 but fails on 10.4
AWS EC2 , Postgres - 10.4, PLV8 - 2.3.4
4. Test 4 - Fail
AWS RDS , Postgres - 10.3 , PLV8 - 2.1.0
Please let me know if any more information is required to assist in this
problem.
Thanks for your help.
2018-06-20 19:06:18 UTC [1955]: [235-1] user=,db=,app=,client= DEBUG: forked
new backend, pid=2861 socket=11
2018-06-20 19:06:18 UTC [2861]: [1-1]
user=[unknown],db=[unknown],app=[unknown],client=localhost LOG: connection
received: host=localhost port=37222
2018-06-20 19:06:18 UTC [2861]: [2-1]
user=[unknown],db=[unknown],app=[unknown],client=localhost DEBUG: SSL
connection from "(anonymous)"
2018-06-20 19:06:18 UTC [2861]: [3-1]
user=postgres,db=procured,app=[unknown],client=localhost DEBUG: postgres
child[2861]: starting with (
2018-06-20 19:06:18 UTC [2861]: [4-1]
user=postgres,db=procured,app=[unknown],client=localhost DEBUG: postgres
2018-06-20 19:06:18 UTC [2861]: [5-1]
user=postgres,db=procured,app=[unknown],client=localhost DEBUG: )
2018-06-20 19:06:18 UTC [2861]: [6-1]
user=postgres,db=procured,app=[unknown],client=localhost DEBUG: InitPostgres
2018-06-20 19:06:18 UTC [2861]: [7-1]
user=postgres,db=procured,app=[unknown],client=localhost DEBUG: my backend ID
is 3
2018-06-20 19:06:18 UTC [2861]: [8-1]
user=postgres,db=procured,app=[unknown],client=localhost DEBUG:
StartTransaction(1) name: unnamed; blockState: DEFAULT; state: INPROGR,
xid/subid/cid: 0/1/0
2018-06-20 19:06:18 UTC [2861]: [9-1]
user=postgres,db=procured,app=[unknown],client=localhost DEBUG: received
password packet
2018-06-20 19:06:18 UTC [2861]: [10-1]
user=postgres,db=procured,app=[unknown],client=localhost LOG: connection
authorized: user=postgres database=procured SSL enabled (protocol=TLSv1.2,
cipher=ECDHE-RSA-AES256-GCM-SHA384, compression=off)
2018-06-20 19:06:18 UTC [2861]: [11-1]
user=postgres,db=procured,app=psql,client=localhost DEBUG:
CommitTransaction(1) name: unnamed; blockState: STARTED; state: INPROGR,
xid/subid/cid: 0/1/0
2018-06-20 19:06:18 UTC [2830]: [2-1] user=,db=,app=,client= DEBUG: snapshot
of 0+0 running transaction ids (lsn 0/72FC0F20 oldest xid 782 latest complete
781 next xid 782)
2018-06-20 19:06:27 UTC [2861]: [12-1]
user=postgres,db=procured,app=psql,client=localhost DEBUG: StartTransaction(1)
name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0
2018-06-20 19:06:27 UTC [2861]: [13-1]
user=postgres,db=procured,app=psql,client=localhost DEBUG: building index
"pg_toast_49152_index" on table "pg_toast_49152"
2018-06-20 19:06:27 UTC [2861]: [14-1]
user=postgres,db=procured,app=psql,client=localhost DEBUG: no icu dir
2018-06-20 19:06:27 UTC [2861]: [15-1]
user=postgres,db=procured,app=psql,client=localhost CONTEXT: PL/pgSQL function
histogram_merge(histogram,histogram) line 3 at RETURN
2018-06-20 19:06:27 UTC [1955]: [236-1] user=,db=,app=,client= DEBUG: reaping
dead processes
2018-06-20 19:06:27 UTC [1955]: [237-1] user=,db=,app=,client= DEBUG: server
process (PID 2861) was terminated by signal 11: Segmentation fault
2018-06-20 19:06:27 UTC [1955]: [238-1] user=,db=,app=,client= DETAIL: Failed
process was running: CREATE MATERIALIZED VIEW mat_view_by_product AS
SELECT
facility_alias_id,
group_type_id,
product_id,
po_date_month,histogram_agg(histogram) AS histogram,
sum(total_spend) AS total_spend,
min(min_price) AS min_price,
max(max_price) AS max_price,
min(min_po_date) AS min_po_date,
max(max_po_date) AS max_po_date,
(array_agg(most_recent_price ORDER BY max_po_date))[1] AS
most_recent_price,
sum(total_eaches) AS total_eaches
FROM
mat_view_by_catalog
GROUP BY
facility_alias_id,
group_type_id,
product_id,
po_date_month;
2018-06-20 19:06:27 UTC [1955]: [239-1] user=,db=,app=,client= LOG: server
process (PID 2861) was terminated by signal 11: Segmentation fault
2018-06-20 19:06:27 UTC [1955]: [240-1] user=,db=,app=,client= DETAIL: Failed
process was running: CREATE MATERIALIZED VIEW mat_view_by_product AS
SELECT
facility_alias_id,
group_type_id,
product_id,
po_date_month,histogram_agg(histogram) AS histogram,
sum(total_spend) AS total_spend,
min(min_price)