Unable to terminate process started from PLV8 function

2018-06-13 Thread Mukesh Chhatani
Hello Team,

We are trying to use PLV8 function to calculate the histograms and while
testing the function
we found that with some of the data, function was going into the infinite
loop.

We tried to kill the session using pg_terminate_backend(pid) but process
could not get killed,
we terminated the process using kill pid still no luck , then we tried ,
kill -9 PID and it terminated postmaster also and restarted the database.

Below is the sample function to reproduce the infinite loop

CREATE FUNCTION test_infinite () returns void as $$  while (true) {(new
Date).toISOString(); } $$ LANGUAGE plv8 IMMUTABLE STRICT;;

Please let me know if someone has ever noticed this or is this the expected
behavior with PLV8 extension or do I have to report the issue to PLV8 or V8
groups.

Thanks for your help in advance.

Regards,
Mukesh


Postgres 10.4 crashing when using PLV8

2018-06-20 Thread Mukesh Chhatani
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)

Re: Postgres 10.4 crashing when using PLV8

2018-06-20 Thread Mukesh Chhatani
Thanks David for the response, I have opened a issue with PLV8 team.

Let me know if I should report this bug to postgres or not, since I was not
sure thus I sent email earlier.

Regards,
Mukesh

On Wed, Jun 20, 2018 at 3:02 PM, David G. Johnston <
david.g.johns...@gmail.com> wrote:

> On Wed, Jun 20, 2018 at 12:46 PM, Mukesh Chhatani <
> chhatani.muk...@gmail.com> wrote:
>
>> 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.
>>
>
> ​These are not the correct place to post possible bug reports for
> third-party extensions.  plV8 has an active Issues listing on GitHub and
> you should post your observations there.  They can report upstream to us if
> there is indeed something specific in core causing their code to fail.
>
> Additionally, in the future if you find that your email is indeed a core
> PostgreSQL issue please just submit it to one of the available lists.  If
> you are unsure pgsql-general is a safe choice.  For this email enough
> information has been provided that our official pgsql-bugs email list (or
> form) would be acceptable and indeed preferred.
>
> David J.​
>
>