Skip to content

Commit

Permalink
Use GetConfigOption to retrieve autovac_max_workers GUC value.
Browse files Browse the repository at this point in the history
The internal variable isn't declared as PGDLLIMPORT so it prevents compilation
on Windows.
  • Loading branch information
rjuju committed Jul 27, 2021
1 parent 1dd82e7 commit 5e1557a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pg_qualstats.c
Expand Up @@ -54,7 +54,7 @@
#include "parser/analyze.h"
#include "parser/parse_node.h"
#include "parser/parsetree.h"
#include "postmaster/autovacuum.h"
#include "postmaster/postmaster.h"
#include "storage/ipc.h"
#include "storage/lwlock.h"
#if PG_VERSION_NUM >= 100000
Expand Down Expand Up @@ -2422,14 +2422,26 @@ pgqs_memsize(void)
static Size
pgqs_sampled_array_size(void)
{
const char *guc_string;
int32 autovac_max_workers;

/*
* autovacuum_max_workers isn't declared as PGDLLEXPORT, so retrieve it
* using GetConfigOption to allow compilation on Windows.
*/
guc_string = GetConfigOption("autovacuum_max_workers",
false, true);

autovac_max_workers = pg_atoi(guc_string, 4, 0);
Assert(autovac_max_workers >= 1 && autovac_max_workers <= MAX_BACKENDS);
/*
* Parallel workers need to be sampled if their original query is also
* sampled. We store in shared mem the sample state for each query,
* identified by their BackendId. If need room for all possible backends,
* plus autovacuum launcher and workers, plus bg workers and an extra one
* since BackendId numerotation starts at 1.
*/
return (sizeof(bool) * (MaxConnections + autovacuum_max_workers + 1
return (sizeof(bool) * (MaxConnections + autovac_max_workers + 1
+ max_worker_processes + 1));
}
#endif
Expand Down

0 comments on commit 5e1557a

Please sign in to comment.