mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-08 22:12:56 +00:00
Report search_path to make it possible to use it in pgbouncer track_extra_parameters (#8303)
## Problem When pooled connections are used, session semantic its not preserved, including GUC settings. Many customers have particular problem with setting search_path. But pgbouncer 1.20 has `track_extra_parameters` settings which allows to track parameters included in startup package which are reported by Postgres. Postgres has [an official list of parameters that it reports to the client](https://www.postgresql.org/docs/15/protocol-flow.html#PROTOCOL-ASYNC). This PR makes Postgres also report `search_path` and so allows to include it in `track_extra_parameters`. ## Summary of changes Set GUC_REPORT flag for `search_path`. ## Checklist before requesting a review - [ ] I have performed a self-review of my code. - [ ] If it is a core feature, I have added thorough tests. - [ ] Do we need to implement analytics? if so did you add the relevant metrics to the dashboard? - [ ] If this PR requires public announcement, mark it with /release-notes label and add several sentences in this section. ## Checklist before merging - [ ] Do not forget to reformat commit message to not include the above checklist --------- Co-authored-by: Konstantin Knizhnik <knizhnik@neon.tech>
This commit is contained in:
committed by
GitHub
parent
b9d2c7bdd5
commit
afb68b0e7e
@@ -32,6 +32,7 @@
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/pg_lsn.h"
|
||||
#include "utils/guc.h"
|
||||
#include "utils/guc_tables.h"
|
||||
#include "utils/wait_event.h"
|
||||
|
||||
#include "extension_server.h"
|
||||
@@ -584,6 +585,40 @@ RestoreRunningXactsFromClog(CheckPoint *checkpoint, TransactionId **xids, int *n
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* pgbouncer is able to track GUCs reported by Postgres.
|
||||
* But most parameters cannot be tracked this way. The only parameters that can be tracked are ones
|
||||
* that Postgres reports to the client. Unfortunately `search_path` is not reported by Postgres:
|
||||
* https://www.postgresql.org/message-id/flat/CAGECzQQ6xFcgrg%2Be0p9mCumtK362TiA6vTiiZKoYbS8OXggwuQ%40mail.gmail.com#be4bfd7a9cf1f0633bdb2d1790a0a1be
|
||||
* This code sets GUC_REPORT flag for `search_path`making it possible to include it in
|
||||
* pgbouncer's `track_extra_parameters` list.
|
||||
*
|
||||
* This code is inspired by how the Citus extension does this, see
|
||||
* https://github.com/citusdata/citus/blob/2a263fe69a707d16ef24378f7650742386b0968f/src/backend/distributed/shared_library_init.c#L2694
|
||||
*/
|
||||
static void
|
||||
ReportSearchPath(void)
|
||||
{
|
||||
#if PG_VERSION_NUM >= 160000
|
||||
int nGucs = 0;
|
||||
struct config_generic **gucs = get_guc_variables(&nGucs);
|
||||
#else
|
||||
struct config_generic **gucs = get_guc_variables();
|
||||
int nGucs = GetNumConfigOptions();
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < nGucs; i++)
|
||||
{
|
||||
struct config_generic *guc = (struct config_generic *) gucs[i];
|
||||
|
||||
if (strcmp(guc->name, "search_path") == 0)
|
||||
{
|
||||
guc->flags |= GUC_REPORT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_PG_init(void)
|
||||
{
|
||||
@@ -627,6 +662,8 @@ _PG_init(void)
|
||||
* extension was loaded will be removed.
|
||||
*/
|
||||
EmitWarningsOnPlaceholders("neon");
|
||||
|
||||
ReportSearchPath();
|
||||
}
|
||||
|
||||
PG_FUNCTION_INFO_V1(pg_cluster_size);
|
||||
|
||||
Reference in New Issue
Block a user