Skip to content

Commit 6cf00c3

Browse files
author
Vladimir Ershov
committed
reread guc in db_role
1 parent ca2dc0f commit 6cf00c3

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

src/pgpro_scheduler.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@
2121
#include "utils/snapmgr.h"
2222
#include "utils/datetime.h"
2323
#include "catalog/pg_db_role_setting.h"
24+
#include "commands/dbcommands.h"
2425

2526
#include "char_array.h"
2627
#include "sched_manager_poll.h"
2728
#include "cron_string.h"
2829
#include "pgpro_scheduler.h"
2930
#include "scheduler_manager.h"
3031
#include "memutils.h"
32+
#include "scheduler_spi_utils.h"
3133

3234

3335
#ifdef PG_MODULE_MAGIC
@@ -69,16 +71,23 @@ worker_spi_sigterm(SIGNAL_ARGS)
6971

7072
/** Some utils **/
7173

72-
void reload_db_role_config(Oid databaseid)
74+
void reload_db_role_config(char *dbname)
7375
{
7476
Relation relsetting;
7577
Snapshot snapshot;
78+
Oid databaseid;
7679

80+
StartTransactionCommand();
81+
databaseid = get_database_oid(dbname, false);
82+
83+
elog(LOG, "start read");
7784
relsetting = heap_open(DbRoleSettingRelationId, AccessShareLock);
7885
snapshot = RegisterSnapshot(GetCatalogSnapshot(DbRoleSettingRelationId));
7986
ApplySetting(snapshot, databaseid, InvalidOid, relsetting, PGC_S_DATABASE);
8087
UnregisterSnapshot(snapshot);
8188
heap_close(relsetting, AccessShareLock);
89+
CommitTransactionCommand();
90+
elog(LOG, "got read");
8291
}
8392

8493
TimestampTz timestamp_add_seconds(TimestampTz to, int add)

src/pgpro_scheduler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ int checkSchedulerNamespace(void);
3434
void manager_worker_main(Datum arg);
3535
pid_t registerManagerWorker(schd_manager_t *man);
3636

37-
void reload_db_role_config(Oid databaseid);
37+
void reload_db_role_config(char *dbname);
3838
TimestampTz timestamp_add_seconds(TimestampTz to, int add);
3939
char *make_date_from_timestamp(TimestampTz ts);
4040
int get_integer_from_string(char *s, int start, int len);

src/scheduler_manager.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,8 +1323,12 @@ void manager_worker_main(Datum arg)
13231323
if(rc & WL_POSTMASTER_DEATH) proc_exit(1);
13241324
if(got_sighup)
13251325
{
1326+
elog(LOG, "manager got sighup");
13261327
got_sighup = false;
13271328
ProcessConfigFile(PGC_SIGHUP);
1329+
elog(LOG, "DONE CONFIG");
1330+
reload_db_role_config(database);
1331+
elog(LOG, "DONE role");
13281332
refresh_scheduler_manager_context(ctx);
13291333
set_slots_stat_report(ctx);
13301334
}

src/scheduler_spi_utils.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,3 +240,4 @@ int execute_spi(const char *sql, char **error)
240240
return execute_spi_sql_with_args(sql, 0, NULL, NULL, NULL, error);
241241
}
242242

243+

0 commit comments

Comments
 (0)