提交 5380cad3 编写于 作者: D Daniel Gustafsson

Fix stat file management for resource queues

pgstat_write_statsfile() failed to write the resource queue statistics
to the stat file which in turn makes the pg_stat_resqueues view empty.

Patch by Github user LJoNe with testcase added by me
上级 06f45085
......@@ -3059,6 +3059,7 @@ pgstat_write_statsfile(bool permanent)
PgStat_StatDBEntry *dbentry;
PgStat_StatTabEntry *tabentry;
PgStat_StatFuncEntry *funcentry;
PgStat_StatQueueEntry *queueentry;
FILE *fpout;
int32 format_id;
const char *tmpfile = permanent ? PGSTAT_STAT_PERMANENT_TMPFILE : pgstat_stat_tmpname;
......@@ -3133,6 +3134,16 @@ pgstat_write_statsfile(bool permanent)
fputc('d', fpout);
}
/*
* Walk through resource queue stats.
*/
hash_seq_init(&fstat, pgStatQueueHash);
while ((queueentry = (PgStat_StatQueueEntry *) hash_seq_search(&fstat)) != NULL)
{
fputc('Q', fpout);
fwrite(queueentry, sizeof(PgStat_StatQueueEntry), 1, fpout);
}
/*
* No more output to be done. Close the temp file and replace the old
* pgstat.stat with it. The ferror() check replaces testing for error
......
......@@ -595,6 +595,25 @@ select * from gp_toolkit.gp_pgdatabase_invalid;
-----------+----------------+--------------+------------+---------------------
(0 rows)
-- Test that the statistics on resource queue usage are properly updated and
-- reflected in the pg_stat_resqueues view
set stats_queue_level=on;
create resource queue q with (active_statements = 10);
create user resqueuetest with resource queue q;
set role resqueuetest;
select 1;
?column?
----------
1
(1 row)
select n_queries_exec from pg_stat_resqueues where queuename = 'q';
n_queries_exec
----------------
1
(1 row)
reset role;
-- GP Readable Data Table
-- Check that the tables created above are present in gp_toolkit.__gp_user_data_tables_readable
-- view.
......
......@@ -340,6 +340,15 @@ select * from gp_toolkit.gp_resq_activity where resqrole = 'toolkit_user1';
-- Should be empty unless there is failure in the segment, it's a view from gp_pgdatabase
select * from gp_toolkit.gp_pgdatabase_invalid;
-- Test that the statistics on resource queue usage are properly updated and
-- reflected in the pg_stat_resqueues view
set stats_queue_level=on;
create resource queue q with (active_statements = 10);
create user resqueuetest with resource queue q;
set role resqueuetest;
select 1;
select n_queries_exec from pg_stat_resqueues where queuename = 'q';
reset role;
-- GP Readable Data Table
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册