Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execute pl/pgsql disconnecting #39

Closed
seouljun opened this issue Mar 9, 2021 · 2 comments
Closed

Execute pl/pgsql disconnecting #39

seouljun opened this issue Mar 9, 2021 · 2 comments

Comments

@seouljun
Copy link

seouljun commented Mar 9, 2021

Hello

I'm trying to analyze AGE source for using create vertex on pl/pgsql.

I tried this script


LOAD 'age';
SET search_path = ag_catalog, age, public;

select create_graph('test');

SELECT * from cypher('test', $$
  CREATE (a:Part {id: '123',value: '1234'})
$$) as (a agtype);

SELECT * from cypher('test', $$
  MATCH (a:Part)
  RETURN a.value
$$) as (a agtype);


CREATE OR REPLACE FUNCTION public.create_graph4(
	)
    RETURNS void
    LANGUAGE 'plpgsql'
AS $BODY$
begin
	LOAD 'age';
	SET search_path = ag_catalog, age, public;
	SELECT * from cypher('test', $$ create(:Part{id:'1234',value:'12345'}) $$) as (a agtype);	
end
$BODY$;
select public.create_graph4();
ERROR

2021-03-09 12:48:38.560 KST [24113] LOG:  server process (PID 26455) was terminated by signal 11: 세그멘테이션 오류
2021-03-09 12:48:38.560 KST [24113] DETAIL:  Failed process was running: select public.create_graph4();
2021-03-09 12:48:38.560 KST [24113] LOG:  terminating any other active server processes
2021-03-09 12:48:38.561 KST [26449] WARNING:  terminating connection because of crash of another server process
2021-03-09 12:48:38.561 KST [26449] 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.
2021-03-09 12:48:38.561 KST [26449] HINT:  In a moment you should be able to reconnect to the database and repeat your command.
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: 2021-03-09 12:48:38.563 KST [26452] WARNING:  terminating connection because of crash of another server process
2021-03-09 12:48:38.563 KST [26452] 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.
2021-03-09 12:48:38.563 KST [26452] HINT:  In a moment you should be able to reconnect to the database and repeat your command.
2021-03-09 12:48:38.564 KST [26457] FATAL:  the database system is in recovery mode
Failed.
!> 2021-03-09 12:48:38.565 KST [24113] LOG:  all server processes terminated; reinitializing
2021-03-09 12:48:38.578 KST [26458] LOG:  database system was interrupted; last known up at 2021-03-09 12:46:40 KST
2021-03-09 12:48:38.772 KST [26458] LOG:  database system was not properly shut down; automatic recovery in progress
2021-03-09 12:48:38.774 KST [26458] LOG:  redo starts at 0/31CF228
2021-03-09 12:48:38.791 KST [26458] LOG:  invalid record length at 0/337ADC8: wanted 24, got 0
2021-03-09 12:48:38.791 KST [26458] LOG:  redo done at 0/337AD60
2021-03-09 12:48:38.791 KST [26458] LOG:  last completed transaction was at log time 2021-03-09 12:48:37.494032+09
2021-03-09 12:48:38.835 KST [24113] LOG:  database system is ready to accept connections

세그멘테이션 오류 -> segmentation error
first start "select public.create_graph4();" -> disconnect
second start "select public.create_graph4();" -> not disconnect
third start "select public.create_graph4();" -> not disconnect

why first time start "select public.create_graph4()" disconnected ?

@JoshInnis
Copy link
Contributor

JoshInnis commented Mar 9, 2021

Hello,

I believe this issue is related to issue #28

In short: the data structure that preserves the information about a CREATE clause does not support moments where the current MemoryContext is destroyed. ie: prepared statements and PL/PGPSQL functionms.

See Here: https://www.postgresql.org/docs/11/spi-memory.html

We need the CREATE clause-- and REMOVE, SET, and eventually MERGE and DELETE (when these are implemented) clauses to store information on disk, so it can handle situations where information needs to be preserved beyond the specific context it was created in.

We will keep this ticket open and updated until this issue is resolved.

@JoshInnis
Copy link
Contributor

Hi,

pl/pgsql Functions are now compatible with the CREATE, SET, REMOVE, and DELETE clauses. 7ba89b0. This commit will be included in release 0.4.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants