Master process got a PANIC and the database goes into recovery mode with the following error message when running queries included with user defined function of PL/R:
2021-06-30 15:40:54.423740 KST,"etluser","bdagpdb",p241108,th1191909504,"0.0.0.0","57951",2021-06-30 15:40:45 KST,0,con288,cmd11,seg-1,,,,sx1,"LOG","00000","execute <unnamed>: select array_outlier_check(array[0.17830450565958245::double precision,0.1015089255490409,0.17129999686423503,0.11107548206268802], 1.2686413983454440)",,,,,,"select array_outlier_check(array[0.17830450565958245::double precision,0.1015089255490409,0.17129999686423503,0.11107548206268802], 1.2686413983454440)",0,,"postgres.c",2740, ~~ snip 2021-06-30 15:40:54.645472 KST,,,p241108,th0,,,2021-06-30 15:40:45 KST,0,con288,cmd12,seg-1,,,,,"PANIC","XX000","Unexpected internal error: Master process received signal SIGSEGV",,,,,,,0,,,,"1 0x7fc34367e5d0 libpthread.so.0 <symbol not found> + 0x4367e5d0 2 0x7fc3388ba7a3 ??:0 3 0x7fc3388bd64d ??:0 4 0x7fc3388b9126 ??:0 5 0x6d06ae postgres <symbol not found> (execQual.c:2162) 6 0x6d5cdd postgres ExecProject (execQual.c:6333) 7 0x6f4efd postgres ExecResult (nodeResult.c:218) 8 0x6c88a8 postgres ExecProcNode (execProcnode.c:970) 9 0x6bfe39 postgres <symbol not found> (tuptable.h:159) 10 0x6c0bac postgres standard_ExecutorRun (execMain.c:952) 11 0x88f647 postgres <symbol not found> (pquery.c:1152) 12 0x891631 postgres PortalRun (pquery.c:999) 13 0x88dfd8 postgres PostgresMain (postgres.c:2765)
The problematic query is shown below and plr-3.0.3-gp6-rhel7-x86_64.gppkg has been installed on GPDB v6.4 in order to run these queries and functions:
CREATE FUNCTION public.array_outlier_check(var1 double precision[], var2 double precision) RETURNS double precision[] LANGUAGE plr NO SQL AS $$ var <- ifelse(var1>var2,1,0) return(var) $$; ALTER FUNCTION public.array_outlier_check(var1 double precision[], var2 double precision) OWNER TO etluser; -- -- Name: array_outlier_check(double precision[], numeric); Type: FUNCTION; Schema: public; Owner: etluser -- CREATE FUNCTION public.array_outlier_check(var1 double precision[], var2 numeric) RETURNS numeric[] LANGUAGE plr NO SQL AS $$ var <- ifelse(var1>var2,1,0) return (var) $$; ALTER FUNCTION public.array_outlier_check(var1 double precision[], var2 numeric) OWNER TO etluser;
This article will discuss the cause and resolution for this issue.
The cause of thus issue is a bug in PL/R when converting the R object to a numeric array. We recommend updating PL/R to v3.0.4 where this issue has been fixed.
For the workaround, the return type should be changed from numeric[] to float8[] in this case if were not able to right away. For example:
From CREATE FUNCTION public.array_outlier_check(var1 double precision[], var2 numeric) RETURNS numeric[] To CREATE FUNCTION public.array_outlier_check(var1 double precision[], var2 numeric) RETURNS float8[]