@@ -101,7 +101,6 @@ static TransactionManager MtmTM =
101
101
// XXX
102
102
bool MtmBackgroundWorker ;
103
103
int MtmReplicationNodeId ;
104
- int MtmMaxNodes ;
105
104
106
105
/*
107
106
* Maximal size of transaction after which transaction is written to the disk.
@@ -249,7 +248,7 @@ MtmSharedShmemStartup()
249
248
ConditionVariableInit (& Mtm -> commit_barrier_cv );
250
249
ConditionVariableInit (& Mtm -> receiver_barrier_cv );
251
250
252
- for (i = 0 ; i < MtmMaxNodes ; i ++ )
251
+ for (i = 0 ; i < MTM_MAX_NODES ; i ++ )
253
252
{
254
253
Mtm -> peers [i ].receiver_pid = InvalidPid ;
255
254
Mtm -> peers [i ].sender_pid = InvalidPid ;
@@ -270,7 +269,7 @@ MtmShmemStartup(void)
270
269
if (PreviousShmemStartupHook )
271
270
PreviousShmemStartupHook ();
272
271
273
- MtmDeadlockDetectorShmemStartup (MtmMaxNodes );
272
+ MtmDeadlockDetectorShmemStartup (MTM_MAX_NODES );
274
273
MtmDDLReplicationShmemStartup ();
275
274
MtmStateShmemStartup ();
276
275
MtmSharedShmemStartup ();
@@ -320,22 +319,6 @@ _PG_init(void)
320
319
NULL
321
320
);
322
321
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
-
339
322
DefineCustomIntVariable (
340
323
"multimaster.trans_spill_threshold" ,
341
324
"Maximal size of transaction after which transaction is written to the disk" ,
@@ -544,9 +527,10 @@ MtmAllApplyWorkersFinished()
544
527
* Check correctness of multimaster configuration
545
528
*/
546
529
static bool
547
- check_config ()
530
+ check_config (int node_id )
548
531
{
549
- bool ok = true;
532
+ bool ok = true;
533
+ int workers_required ;
550
534
551
535
if (max_prepared_xacts < 1 )
552
536
{
@@ -556,15 +540,21 @@ check_config()
556
540
ok = false;
557
541
}
558
542
543
+ if (node_id <= 0 || node_id > MTM_MAX_NODES )
559
544
{
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;
568
558
}
569
559
570
560
if (wal_level != WAL_LEVEL_LOGICAL )
@@ -575,19 +565,19 @@ check_config()
575
565
ok = false;
576
566
}
577
567
578
- if (max_wal_senders < MtmMaxNodes )
568
+ if (max_wal_senders < node_id )
579
569
{
580
570
mtm_log (WARNING ,
581
571
"multimaster requires max_wal_senders >= %d (multimaster.max_nodes), " ,
582
- MtmMaxNodes );
572
+ node_id );
583
573
ok = false;
584
574
}
585
575
586
- if (max_replication_slots < MtmMaxNodes )
576
+ if (max_replication_slots < node_id )
587
577
{
588
578
mtm_log (WARNING ,
589
579
"multimaster requires max_replication_slots >= %d (multimaster.max_nodes), " ,
590
- MtmMaxNodes );
580
+ node_id );
591
581
ok = false;
592
582
}
593
583
@@ -745,12 +735,7 @@ mtm_after_node_create(PG_FUNCTION_ARGS)
745
735
& is_self_isnull ));
746
736
Assert (!is_self_isnull );
747
737
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 ))
754
739
mtm_log (ERROR , "multimaster can't start with current configs" );
755
740
756
741
mtm_log (NodeMgmt , "Creating node%d" , node_id );
@@ -1100,7 +1085,7 @@ MtmLoadConfig()
1100
1085
if (rc < 0 || rc != SPI_OK_SELECT )
1101
1086
mtm_log (ERROR , "Failed to load saved nodes" );
1102
1087
1103
- Assert (SPI_processed <= MtmMaxNodes );
1088
+ Assert (SPI_processed <= MTM_MAX_NODES );
1104
1089
1105
1090
cfg -> n_nodes = 0 ;
1106
1091
cfg -> my_node_id = 0 ;
0 commit comments