Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1a0e6ba

Browse files
committed
2 parents 05b6876 + 8b3b9e8 commit 1a0e6ba

15 files changed

+420
-198
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ lib*.pc
3939
/Debug/
4040
/Release/
4141
/tmp_install/
42+
<<<<<<< HEAD
4243
/contrib/mmts/tests/node*
4344
/install/
44-
/.vscode/
45+
/.vscode/

contrib/mmts/bgwpool.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static void BgwPoolMainLoop(Datum arg)
2525
void* work;
2626

2727
BackgroundWorkerUnblockSignals();
28-
BackgroundWorkerInitializeConnection(pool->dbname, NULL);
28+
BackgroundWorkerInitializeConnection(pool->dbname, pool->dbuser);
2929

3030
while(true) {
3131
PGSemaphoreLock(&pool->available);
@@ -63,7 +63,7 @@ static void BgwPoolMainLoop(Datum arg)
6363
}
6464
}
6565

66-
void BgwPoolInit(BgwPool* pool, BgwPoolExecutor executor, char const* dbname, size_t queueSize, size_t nWorkers)
66+
void BgwPoolInit(BgwPool* pool, BgwPoolExecutor executor, char const* dbname, char const* dbuser, size_t queueSize, size_t nWorkers)
6767
{
6868
pool->queue = (char*)ShmemAlloc(queueSize);
6969
pool->executor = executor;
@@ -80,7 +80,8 @@ void BgwPoolInit(BgwPool* pool, BgwPoolExecutor executor, char const* dbname, si
8080
pool->pending = 0;
8181
pool->nWorkers = nWorkers;
8282
pool->lastPeakTime = 0;
83-
strcpy(pool->dbname, dbname);
83+
strncpy(pool->dbname, dbname, MAX_DBNAME_LEN);
84+
strncpy(pool->dbuser, dbuser, MAX_DBUSER_LEN);
8485
}
8586

8687
timestamp_t BgwGetLastPeekTime(BgwPool* pool)
@@ -98,7 +99,7 @@ void BgwPoolStart(int nWorkers, BgwPoolConstructor constructor)
9899
worker.bgw_start_time = BgWorkerStart_ConsistentState;
99100
worker.bgw_main = BgwPoolMainLoop;
100101
worker.bgw_restart_time = MULTIMASTER_BGW_RESTART_TIMEOUT;
101-
102+
102103
for (i = 0; i < nWorkers; i++) {
103104
BgwPoolExecutorCtx* ctx = (BgwPoolExecutorCtx*)malloc(sizeof(BgwPoolExecutorCtx));
104105
snprintf(worker.bgw_name, BGW_MAXLEN, "bgw_pool_worker_%d", i+1);

contrib/mmts/bgwpool.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ typedef void(*BgwPoolExecutor)(int id, void* work, size_t size);
1010
typedef uint64 timestamp_t;
1111

1212
#define MAX_DBNAME_LEN 30
13+
#define MAX_DBUSER_LEN 30
1314
#define MULTIMASTER_BGW_RESTART_TIMEOUT 1 /* seconds */
1415

1516
extern timestamp_t MtmGetSystemTime(void); /* non-adjusted current system time */
@@ -30,14 +31,15 @@ typedef struct
3031
time_t lastPeakTime;
3132
bool producerBlocked;
3233
char dbname[MAX_DBNAME_LEN];
34+
char dbuser[MAX_DBUSER_LEN];
3335
char* queue;
3436
} BgwPool;
3537

3638
typedef BgwPool*(*BgwPoolConstructor)(void);
3739

3840
extern void BgwPoolStart(int nWorkers, BgwPoolConstructor constructor);
3941

40-
extern void BgwPoolInit(BgwPool* pool, BgwPoolExecutor executor, char const* dbname, size_t queueSize, size_t nWorkers);
42+
extern void BgwPoolInit(BgwPool* pool, BgwPoolExecutor executor, char const* dbname, char const* dbuser, size_t queueSize, size_t nWorkers);
4143

4244
extern void BgwPoolExecute(BgwPool* pool, void* work, size_t size);
4345

contrib/mmts/multimaster--1.0.sql

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ CREATE FUNCTION mtm.drop_node(node integer, drop_slot bool default false) RETURN
1313
AS 'MODULE_PATHNAME','mtm_drop_node'
1414
LANGUAGE C;
1515

16-
CREATE FUNCTION mtm.add_node(conn_str cstring) RETURNS void
17-
AS 'MODULE_PATHNAME','mtm_add_node'
18-
LANGUAGE C;
16+
-- -- XXX: cstring as an argument breaks sanity check
17+
-- CREATE FUNCTION mtm.add_node(conn_str cstring) RETURNS void
18+
-- AS 'MODULE_PATHNAME','mtm_add_node'
19+
-- LANGUAGE C;
1920

2021
-- Create replication slot for the node which was previously dropped together with it's slot
2122
CREATE FUNCTION mtm.recover_node(node integer) RETURNS void
@@ -69,7 +70,7 @@ CREATE FUNCTION mtm.inject_2pc_error(stage integer) RETURNS void
6970
AS 'MODULE_PATHNAME','mtm_inject_2pc_error'
7071
LANGUAGE C;
7172

72-
CREATE TABLE IF NOT EXISTS mtm.ddl_log (issued timestamp with time zone not null, query text);
73+
-- CREATE TABLE IF NOT EXISTS public.ddl_log (issued timestamp with time zone not null, query text);
7374

74-
CREATE TABLE IF NOT EXISTS mtm.local_tables(rel_schema text, rel_name text, primary key(rel_schema, rel_name));
75+
-- CREATE TABLE IF NOT EXISTS mtm.local_tables(rel_schema text, rel_name text, primary key(rel_schema, rel_name));
7576

0 commit comments

Comments
 (0)