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

Segmentation fault CASE WHEN with DO block #7381

Closed
DenSaoPin opened this issue Dec 13, 2023 · 0 comments · Fixed by #7554
Closed

Segmentation fault CASE WHEN with DO block #7381

DenSaoPin opened this issue Dec 13, 2023 · 0 comments · Fixed by #7554

Comments

@DenSaoPin
Copy link

DenSaoPin commented Dec 13, 2023

When using the CASE WHEN expression in the body of the function that is used in the DO block, a segmentation error occurs.
If you call with a simple parameter in the DO block, then the error is not observed.
There is no such error in pure postgresql.
I have checked several versions of citus and this problem has been observed everywhere.

Example:

CREATE OR REPLACE FUNCTION public.test_err(v1 text)
 RETURNS text
 LANGUAGE plpgsql
 SECURITY DEFINER
AS $function$

begin
  return v1 || ' - ok';
END;
$function$;
do $$ declare 
 lNewValues text;
 val text;
begin 
 val = 'test';
 lNewValues = public.test_err(v1 => case when val::text = 'test'::text then 'yes' else 'no' end);
 raise notice 'lNewValues= %', lNewValues;
end;$$ ;

Short log:

14:11:30.082 [2673] LOG:  server process (PID 14341) was terminated by signal 11: Segmentation fault
14:11:30.082 [2673] DETAIL:  Failed process was running: do $$ declare 
     lNewValues text;
     val text;
    begin 
     val = 'test';
     lNewValues = public.test_err(v1 => case when val::text = 'test'::text then 'yes' else 'no' end);
    
     raise notice 'lNewValues= %', lNewValues;
    end;$$ ;
14:11:30.082 [2673] LOG:  terminating any other active server processes
14:11:30.083 [14185] LOG:  could not receive data from client: Connection reset by peer
14:11:30.086 [14343] FATAL:  the database system is in recovery mode
14:11:30.087 [2673] LOG:  all server processes terminated; reinitializing
14:11:30.123 [14344] LOG:  database system was interrupted; last known up at 13:51:57 
14:11:30.136 [14344] LOG:  database system was not properly shut down; automatic recovery in progress
14:11:30.138 [14344] LOG:  redo starts at 2/BA198838
14:11:30.138 [14344] LOG:  invalid record length at 2/BA198870: wanted 24, got 0
14:11:30.138 [14344] LOG:  redo done at 2/BA198838 system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.00 s
14:11:30.146 [14345] LOG:  checkpoint starting: end-of-recovery immediate wait
14:11:30.152 [14345] LOG:  checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.002 s, sync=0.001 s, total=0.007 s; sync files=2, longest=0.001 s, average=0.001 s; distance=0 kB, estimate=0 kB
14:11:30.163 [2673] LOG:  database system is ready to accept connections
14:11:31.161 [7821] WARNING:  111:5432:SELECT waiting_pid, waiting_node_id, waiting_transaction_num, waiting_transaction_stamp, blocking_pid, blocking_node_id, blocking_transaction_num, blocking_transaction_stamp, blocking_transaction_waiting FROM dump_local_wait_edges() 
14:11:31.161 [7821] CONTEXT:  Citus maintenance daemon for database 244221 user 10
14:11:31.161 [7821] WARNING:  SSL SYSCALL error: EOF detected
14:11:31.161 [7821] CONTEXT:  while executing command on 127.0.0.1:5432
copetol pushed a commit to copetol/citus that referenced this issue Mar 7, 2024
JelteF pushed a commit that referenced this issue Mar 8, 2024
When using a CASE WHEN expression in the body
of the function that is used in the DO block, a segmentation
fault occured. This fixes that.

Fixes #7381

---------

Co-authored-by: Konstantin Morozov <vzbdryn@yahoo.com>
emelsimsek pushed a commit that referenced this issue Mar 11, 2024
When using a CASE WHEN expression in the body
of the function that is used in the DO block, a segmentation
fault occured. This fixes that.

Fixes #7381

---------

Co-authored-by: Konstantin Morozov <vzbdryn@yahoo.com>
JelteF pushed a commit that referenced this issue Apr 16, 2024
When using a CASE WHEN expression in the body
of the function that is used in the DO block, a segmentation
fault occured. This fixes that.

Fixes #7381

---------

Co-authored-by: Konstantin Morozov <vzbdryn@yahoo.com>
(cherry picked from commit 12f5643)
JelteF pushed a commit that referenced this issue Apr 16, 2024
When using a CASE WHEN expression in the body
of the function that is used in the DO block, a segmentation
fault occured. This fixes that.

Fixes #7381

---------

Co-authored-by: Konstantin Morozov <vzbdryn@yahoo.com>
(cherry picked from commit 12f5643)
JelteF pushed a commit that referenced this issue Apr 16, 2024
When using a CASE WHEN expression in the body
of the function that is used in the DO block, a segmentation
fault occured. This fixes that.

Fixes #7381

---------

Co-authored-by: Konstantin Morozov <vzbdryn@yahoo.com>
(cherry picked from commit 12f5643)
JelteF pushed a commit that referenced this issue Apr 16, 2024
When using a CASE WHEN expression in the body
of the function that is used in the DO block, a segmentation
fault occured. This fixes that.

Fixes #7381

---------

Co-authored-by: Konstantin Morozov <vzbdryn@yahoo.com>
(cherry picked from commit 12f5643)
JelteF pushed a commit that referenced this issue Apr 17, 2024
When using a CASE WHEN expression in the body
of the function that is used in the DO block, a segmentation
fault occured. This fixes that.

Fixes #7381

---------

Co-authored-by: Konstantin Morozov <vzbdryn@yahoo.com>
(cherry picked from commit 12f5643)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants