When migrating from 4.3.x to 5.x or 6.x the session_state function fails
search cancel

When migrating from 4.3.x to 5.x or 6.x the session_state function fails

book

Article ID: 296677

calendar_today

Updated On:

Products

VMware Tanzu Greenplum

Issue/Introduction

The following function can be created in 4.3.x to monitor memory entries for a session:
CREATE FUNCTION public.session_state_memory_entries_f()
RETURNS SETOF record AS '$libdir/gp_session_state', 'gp_session_state_memory_entries'
LANGUAGE c
IMMUTABLE
NO SQL;
gpadmin=# select version();
                                                                        version                                                                        
-------------------------------------------------------------------------------------------------------------------------------------------------------
 PostgreSQL 8.2.15 (Greenplum Database 4.3.33.7 build 1) on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled on May  7 2020 01:36:38
(1 row)

gpadmin=# CREATE FUNCTION public.session_state_memory_entries_f() RETURNS SETOF record AS '$libdir/gp_session_state', 'gp_session_state_memory_entries' LANGUAGE c IMMUTABLE NO SQL;
CREATE FUNCTION
gpadmin=# select public.session_state_memory_entries_f();
              session_state_memory_entries_f               
-----------------------------------------------------------
 (-1,25,17,0,1,0,-1,0,0,"2021-04-22 17:05:10.206378+00")
 (-1,2795,15,0,1,1,-1,0,0,"2021-04-23 17:46:26.607144+00")
(2 rows)

In 5.x and 6.x, this function fails:
gpadmin=# select version();
                                                                                                version                                                                                                
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 PostgreSQL 9.4.24 (Greenplum Database 6.12.0 build commit:4c176763c7619fb678ce38095e6b3e8fb9548186) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Oct 28 2020 19:42:15

gpadmin=# CREATE FUNCTION public.session_state_memory_entries_f() RETURNS SETOF record AS '$libdir/gp_session_state', 'gp_session_state_memory_entries' LANGUAGE c IMMUTABLE NO SQL;
ERROR:  could not access file "$libdir/gp_session_state": No such file or directory


Environment

Product Version: 6.15

Resolution

The gp_session_state file that existed in 4.3.x was changed to a different file in 5.x. and 6.x.

Use the following function instead:
gpadmin=# CREATE FUNCTION public.session_state_memory_entries_f() RETURNS SETOF record AS '$libdir/gp_session_state_memory_stats', 'gp_session_state_memory_entries' LANGUAGE c IMMUTABLE NO SQL;
CREATE FUNCTION
gpadmin=# select public.session_state_memory_entries_f();
             session_state_memory_entries_f              
---------------------------------------------------------
 (-1,1,1,0,1,1,-1,0,0,"2000-01-01 00:00:00+00")
 (-1,2,1,0,1,1,-1,0,0,"2000-01-01 00:00:00+00")
 (-1,26,15,0,1,1,-1,0,0,"2021-04-23 17:53:07.060572+00")
(3 rows)