Skip to content
Permalink
Browse files
HAWQ-1842. add session_state.session_level_memory_consumption
  • Loading branch information
ztao1987 committed Jul 3, 2022
1 parent e6a637e commit de18899bebbeb68bb9547fdee89272e1b5904945
Showing 5 changed files with 21 additions and 20 deletions.
@@ -454,7 +454,7 @@ void *gp_realloc(void *ptr, int64 sz, int64 newsz)
}
#endif

if(!ret)
if(newsz && !ret)
{
Assert(0 < size_diff);
VmemTracker_ReleaseVmem(size_diff);
@@ -16,7 +16,7 @@ include $(top_builddir)/src/Makefile.global
DIRS = initdb ipcclean pg_ctl pg_dump pgbench \
psql scripts pg_config pg_controldata pg_resetxlog \
gpfilesystem/hdfs gpmirrortransition gpupgrade \
gpfusion gp_workfile_mgr gpcheckhdfs gpfdist gpoptutils
gpfusion gp_workfile_mgr gpcheckhdfs gpfdist gpoptutils gp_session_state

all install installdirs uninstall distprep clean distclean maintainer-clean:
@for dir in $(DIRS); do echo "build $$dir"; $(MAKE) -C $$dir $@ || exit; done
@@ -62,24 +62,27 @@ GRANT EXECUTE ON FUNCTION session_state_memory_entries_f() TO public;
-- List of memory usage entries for sessions
--
--------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION create_segment_proxy() RETURNS text AS
$$
DECLARE
segCount int;
cmd text;
BEGIN
SELECT count(*) from gp_segment_configuration where role = 'p' and status = 'u'
into segCount;
cmd := 'create readable external web table segments(t int)
execute ''echo $GP_SEGMENT_ID'' on ' || segCount || ' format ''text''';
EXECUTE cmd;
RETURN cmd;
END;
$$ LANGUAGE PLPGSQL;
SELECT create_segment_proxy();


CREATE VIEW session_level_memory_consumption AS
WITH all_entries AS (
SELECT C.*
FROM gp_toolkit.__gp_localid, session_state_memory_entries_f() AS C (
segid int,
sessionid int,
vmem_mb int,
runaway_status int,
qe_count int,
active_qe_count int,
dirty_qe_count int,
runaway_vmem_mb int,
runaway_command_cnt int
)
UNION ALL
SELECT C.*
FROM gp_toolkit.__gp_masterid, session_state_memory_entries_f() AS C (
FROM session_state.segments, session_state_memory_entries_f() AS C (
segid int,
sessionid int,
vmem_mb int,
@@ -125,7 +125,7 @@ gp_session_state_memory_entries(PG_FUNCTION_ARGS)
bool nulls[NUM_SESSION_STATE_MEMORY_ELEM];
MemSet(nulls, 0, sizeof(nulls));

values[0] = Int32GetDatum(Gp_segment);
values[0] = Int32GetDatum(GpIdentity.segindex);
values[1] = Int32GetDatum(sessionState.sessionId);
values[2] = Int32GetDatum(VmemTracker_ConvertVmemChunksToMB(sessionState.sessionVmem));
values[3] = Int32GetDatum(sessionState.runawayStatus);
@@ -3,8 +3,6 @@ SET search_path = session_state;

BEGIN;

DROP VIEW session_state_memory_entries;
DROP FUNCTION session_state_memory_entries_f();
DROP SCHEMA session_state;
DROP SCHEMA session_state CASCADE;

COMMIT;

0 comments on commit de18899

Please sign in to comment.