Skip to content

Commit 7cd2895

Browse files
committed
Move NEON_AUTH_TOKEN to a builtin GUC
This environment variable is used as the password to connect to another postgres instance as the walreceiver. The purpose of moving to a GUC is so that we can reload the storage auth token periodically. Signed-off-by: Tristan Partin <[email protected]>
1 parent b740647 commit 7cd2895

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

src/backend/replication/libpqwalreceiver/libpqwalreceiver.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ libpqrcv_connect(const char *conninfo, bool logical, bool must_use_password,
136136
/* BEGIN_NEON */
137137
const char *keys[7];
138138
const char *vals[7];
139-
char * neon_auth_token = NULL;
140139
/* END_NEON */
141140
int i = 0;
142141

@@ -159,16 +158,14 @@ libpqrcv_connect(const char *conninfo, bool logical, bool must_use_password,
159158
/* BEGIN_NEON */
160159
if (pg_strcasecmp(appname, "walreceiver") == 0)
161160
{
162-
neon_auth_token = getenv("NEON_AUTH_TOKEN");
163-
if (neon_auth_token != NULL)
161+
if (neon_storage_auth_token[0] != '\0')
164162
{
165-
elog(LOG, "Use NEON_AUTH_TOKEN to connect");
166163
keys[++i] = "password";
167-
vals[i] = neon_auth_token;
164+
vals[i] = neon_storage_auth_token;
168165
}
169166
else
170167
{
171-
elog(LOG, "NEON_AUTH_TOKEN is undefined in the environment");
168+
elog(LOG, "no storage authentication token set");
172169
}
173170
}
174171
/* END_NEON */

src/backend/replication/walreceiver.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
int wal_receiver_status_interval;
9191
int wal_receiver_timeout;
9292
bool hot_standby_feedback;
93+
char *neon_storage_auth_token;
9394

9495
/* libpqwalreceiver connection */
9596
static WalReceiverConn *wrconn = NULL;

src/backend/utils/misc/guc_tables.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
#include "replication/logicallauncher.h"
6767
#include "replication/slot.h"
6868
#include "replication/syncrep.h"
69+
#include "replication/walreceiver.h"
6970
#include "storage/bufmgr.h"
7071
#include "storage/large_object.h"
7172
#include "storage/pg_shmem.h"
@@ -4639,6 +4640,18 @@ struct config_string ConfigureNamesString[] =
46394640
check_restrict_nonsystem_relation_kind, assign_restrict_nonsystem_relation_kind, NULL
46404641
},
46414642

4643+
4644+
{
4645+
{"neon_storage_auth_token", PGC_SUSET, REPLICATION_STANDBY,
4646+
"Authentication token for Neon storage",
4647+
NULL,
4648+
GUC_SUPERUSER_ONLY
4649+
},
4650+
&neon_storage_auth_token,
4651+
"",
4652+
NULL, NULL, NULL
4653+
},
4654+
46424655
/* End-of-list marker */
46434656
{
46444657
{NULL, 0, 0, NULL, NULL}, NULL, NULL, NULL, NULL, NULL

src/include/replication/walreceiver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
extern PGDLLIMPORT int wal_receiver_status_interval;
3131
extern PGDLLIMPORT int wal_receiver_timeout;
3232
extern PGDLLIMPORT bool hot_standby_feedback;
33+
extern PGDLLIMPORT char *neon_storage_auth_token;
3334

3435
/*
3536
* MAXCONNINFO: maximum size of a connection string.

0 commit comments

Comments
 (0)