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

Commit 0736b7c

Browse files
danolivokelvich
authored andcommitted
Remove MtmMaxNodes GUC. The check_config() routine use node_id instead of MtmMaxNodes fofr checking limits of PostgreSQL valuable GUC's.
1 parent 9cc5867 commit 0736b7c

File tree

5 files changed

+34
-50
lines changed

5 files changed

+34
-50
lines changed

src/ddl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1482,7 +1482,7 @@ AdjustCreateSequence(List *options)
14821482

14831483
if (!has_increment)
14841484
{
1485-
DefElem *defel = makeDefElem("increment", (Node *) makeInteger(MtmMaxNodes), -1);
1485+
DefElem *defel = makeDefElem("increment", (Node *) makeInteger(MTM_MAX_NODES), -1);
14861486
options = lappend(options, defel);
14871487
}
14881488

src/include/multimaster.h

-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ extern int MtmHeartbeatSendTimeout;
199199
extern int MtmHeartbeatRecvTimeout;
200200
extern char *MtmRefereeConnStr;
201201
extern int MtmMaxWorkers;
202-
extern int MtmMaxNodes;
203202
extern bool MtmBreakConnection;
204203

205204
extern void MtmSleep(int64 interval);

src/multimaster.c

+25-40
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ static TransactionManager MtmTM =
101101
// XXX
102102
bool MtmBackgroundWorker;
103103
int MtmReplicationNodeId;
104-
int MtmMaxNodes;
105104

106105
/*
107106
* Maximal size of transaction after which transaction is written to the disk.
@@ -249,7 +248,7 @@ MtmSharedShmemStartup()
249248
ConditionVariableInit(&Mtm->commit_barrier_cv);
250249
ConditionVariableInit(&Mtm->receiver_barrier_cv);
251250

252-
for (i = 0; i < MtmMaxNodes; i++)
251+
for (i = 0; i < MTM_MAX_NODES; i++)
253252
{
254253
Mtm->peers[i].receiver_pid = InvalidPid;
255254
Mtm->peers[i].sender_pid = InvalidPid;
@@ -270,7 +269,7 @@ MtmShmemStartup(void)
270269
if (PreviousShmemStartupHook)
271270
PreviousShmemStartupHook();
272271

273-
MtmDeadlockDetectorShmemStartup(MtmMaxNodes);
272+
MtmDeadlockDetectorShmemStartup(MTM_MAX_NODES);
274273
MtmDDLReplicationShmemStartup();
275274
MtmStateShmemStartup();
276275
MtmSharedShmemStartup();
@@ -320,22 +319,6 @@ _PG_init(void)
320319
NULL
321320
);
322321

323-
// XXX
324-
DefineCustomIntVariable(
325-
"multimaster.max_nodes",
326-
"Maximal number of cluster nodes",
327-
"This parameters allows to add new nodes to the cluster, default value 0 restricts number of nodes to one specified in multimaster.conn_strings",
328-
&MtmMaxNodes,
329-
6,
330-
0,
331-
MTM_MAX_NODES,
332-
PGC_POSTMASTER,
333-
0,
334-
NULL,
335-
NULL,
336-
NULL
337-
);
338-
339322
DefineCustomIntVariable(
340323
"multimaster.trans_spill_threshold",
341324
"Maximal size of transaction after which transaction is written to the disk",
@@ -544,9 +527,10 @@ MtmAllApplyWorkersFinished()
544527
* Check correctness of multimaster configuration
545528
*/
546529
static bool
547-
check_config()
530+
check_config(int node_id)
548531
{
549-
bool ok = true;
532+
bool ok = true;
533+
int workers_required;
550534

551535
if (max_prepared_xacts < 1)
552536
{
@@ -556,15 +540,21 @@ check_config()
556540
ok = false;
557541
}
558542

543+
if (node_id <= 0 || node_id > MTM_MAX_NODES)
559544
{
560-
int workers_required = 2 * MTM_MAX_NODES + 1;
561-
if (max_worker_processes < workers_required)
562-
{
563-
mtm_log(WARNING,
564-
"multimaster requires max_worker_processes >= %d",
565-
workers_required);
566-
ok = false;
567-
}
545+
mtm_log(WARNING,
546+
"node_id should be in range from 1 to %d, but %d is given",
547+
MTM_MAX_NODES, node_id);
548+
ok = false;
549+
}
550+
551+
workers_required = 2 * node_id + 1;
552+
if (max_worker_processes < workers_required)
553+
{
554+
mtm_log(WARNING,
555+
"multimaster requires max_worker_processes >= %d",
556+
workers_required);
557+
ok = false;
568558
}
569559

570560
if (wal_level != WAL_LEVEL_LOGICAL)
@@ -575,19 +565,19 @@ check_config()
575565
ok = false;
576566
}
577567

578-
if (max_wal_senders < MtmMaxNodes)
568+
if (max_wal_senders < node_id)
579569
{
580570
mtm_log(WARNING,
581571
"multimaster requires max_wal_senders >= %d (multimaster.max_nodes), ",
582-
MtmMaxNodes);
572+
node_id);
583573
ok = false;
584574
}
585575

586-
if (max_replication_slots < MtmMaxNodes)
576+
if (max_replication_slots < node_id)
587577
{
588578
mtm_log(WARNING,
589579
"multimaster requires max_replication_slots >= %d (multimaster.max_nodes), ",
590-
MtmMaxNodes);
580+
node_id);
591581
ok = false;
592582
}
593583

@@ -745,12 +735,7 @@ mtm_after_node_create(PG_FUNCTION_ARGS)
745735
&is_self_isnull));
746736
Assert(!is_self_isnull);
747737

748-
if (node_id <= 0 || node_id > MTM_MAX_NODES)
749-
mtm_log(ERROR,
750-
"node_id should be in range from 1 to %d, but %d is given",
751-
MTM_MAX_NODES, node_id);
752-
753-
if (!check_config())
738+
if (!check_config(node_id))
754739
mtm_log(ERROR, "multimaster can't start with current configs");
755740

756741
mtm_log(NodeMgmt, "Creating node%d", node_id);
@@ -1100,7 +1085,7 @@ MtmLoadConfig()
11001085
if (rc < 0 || rc != SPI_OK_SELECT)
11011086
mtm_log(ERROR, "Failed to load saved nodes");
11021087

1103-
Assert(SPI_processed <= MtmMaxNodes);
1088+
Assert(SPI_processed <= MTM_MAX_NODES);
11041089

11051090
cfg->n_nodes = 0;
11061091
cfg->my_node_id = 0;

src/pglogical_receiver.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ pglogical_receiver_main(Datum main_arg)
623623
}
624624
else
625625
{
626-
spvector = palloc0(MtmMaxNodes * sizeof(Syncpoint));
626+
spvector = palloc0(MTM_MAX_NODES * sizeof(Syncpoint));
627627
spvector[receiver_ctx.node_id - 1] = SyncpointGetLatest(receiver_ctx.node_id);
628628
filter_map = RecoveryFilterLoad(receiver_ctx.node_id, spvector, receiver_mtm_cfg);
629629
remote_start = spvector[receiver_ctx.node_id - 1].origin_lsn;
@@ -640,7 +640,7 @@ pglogical_receiver_main(Datum main_arg)
640640
appendStringInfo(message, "\t remote_start = %"INT64_MODIFIER"x\n", remote_start);
641641

642642
appendStringInfo(message, "\t syncpoint_vector (origin/local) = {");
643-
for (i = 0; i < MtmMaxNodes; i++)
643+
for (i = 0; i < MTM_MAX_NODES; i++)
644644
{
645645
if (spvector[i].origin_lsn != InvalidXLogRecPtr || spvector[i].local_lsn != InvalidXLogRecPtr)
646646
{

src/syncpoint.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ SyncpointGetLatest(int node_id)
287287
char *sql;
288288
Syncpoint sp;
289289

290-
Assert(node_id > 0 && node_id <= MtmMaxNodes);
290+
Assert(node_id > 0 && node_id <= MTM_MAX_NODES);
291291

292292
memset(&sp, '\0', sizeof(Syncpoint));
293293
sp.local_lsn = InvalidXLogRecPtr;
@@ -350,7 +350,7 @@ SyncpointGetAllLatest()
350350
int rc;
351351
Syncpoint *spvector;
352352

353-
spvector = (Syncpoint *) palloc0(MtmMaxNodes * sizeof(Syncpoint));
353+
spvector = (Syncpoint *) palloc0(MTM_MAX_NODES * sizeof(Syncpoint));
354354

355355
/* Init SPI */
356356
StartTransactionCommand();
@@ -371,7 +371,7 @@ SyncpointGetAllLatest()
371371
TupleDesc tupdesc = SPI_tuptable->tupdesc;
372372
int i;
373373

374-
Assert(SPI_processed <= MtmMaxNodes);
374+
Assert(SPI_processed <= MTM_MAX_NODES);
375375

376376
for (i = 0; i < SPI_processed; i++)
377377
{
@@ -383,7 +383,7 @@ SyncpointGetAllLatest()
383383
node_id = DatumGetInt32(SPI_getbinval(tup, tupdesc, 1, &isnull));
384384
Assert(!isnull);
385385
Assert(TupleDescAttr(tupdesc, 0)->atttypid == INT4OID);
386-
Assert(node_id > 0 && node_id <= MtmMaxNodes);
386+
Assert(node_id > 0 && node_id <= MTM_MAX_NODES);
387387

388388
origin_lsn = DatumGetInt64(SPI_getbinval(tup, tupdesc, 2, &isnull));
389389
Assert(!isnull);
@@ -430,7 +430,7 @@ QueryRecoveryHorizon(PGconn *conn, int node_id, Syncpoint *local_spvector)
430430

431431
/* serialize filter_vector */
432432
initStringInfo(&serialized_lsns);
433-
for (i = 0; i < MtmMaxNodes; i++)
433+
for (i = 0; i < MTM_MAX_NODES; i++)
434434
{
435435
if (local_spvector[i].origin_lsn != InvalidXLogRecPtr &&
436436
i + 1 != node_id)
@@ -502,7 +502,7 @@ RecoveryFilterLoad(int filter_node_id, Syncpoint *spvector, MtmConfig *mtm_cfg)
502502
Assert(current_last_lsn != InvalidXLogRecPtr);
503503

504504
/* start from minimal among all of syncpoints */
505-
for (i = 0; i < MtmMaxNodes; i++)
505+
for (i = 0; i < MTM_MAX_NODES; i++)
506506
{
507507
if (start_lsn > spvector[i].local_lsn &&
508508
spvector[i].local_lsn != InvalidXLogRecPtr)

0 commit comments

Comments
 (0)