@@ -101,7 +101,6 @@ static TransactionManager MtmTM =
101101// XXX
102102bool MtmBackgroundWorker ;
103103int 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 */
546529static 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 ;
0 commit comments