@@ -1935,6 +1935,68 @@ static void MtmSplitConnStrs(void)
19351935 pfree (copy );
19361936}
19371937
1938+ static bool ConfigIsSane (void )
1939+ {
1940+ bool ok = true;
1941+
1942+ if (DefaultXactIsoLevel != XACT_REPEATABLE_READ )
1943+ {
1944+ elog (WARNING , "multimaster requires default_transaction_isolation = 'repeatable read'" );
1945+ ok = false;
1946+ }
1947+
1948+ if (MtmMaxNodes < 1 )
1949+ {
1950+ elog (WARNING , "multimaster requires multimaster.max_nodes > 0" );
1951+ ok = false;
1952+ }
1953+
1954+ if (max_prepared_xacts < 1 )
1955+ {
1956+ elog (WARNING ,
1957+ "multimaster requires max_prepared_transactions > 0, "
1958+ "because all transactions are implicitly two-phase" );
1959+ ok = false;
1960+ }
1961+
1962+ {
1963+ int workers_required = 2 * MtmMaxNodes + MtmWorkers + 1 ;
1964+ if (max_worker_processes < workers_required )
1965+ {
1966+ elog (WARNING ,
1967+ "multimaster requires max_worker_processes >= %d" ,
1968+ workers_required );
1969+ ok = false;
1970+ }
1971+ }
1972+
1973+ if (wal_level != WAL_LEVEL_LOGICAL )
1974+ {
1975+ elog (WARNING ,
1976+ "multimaster requires wal_level = 'logical', "
1977+ "because it is build on top of logical replication" );
1978+ ok = false;
1979+ }
1980+
1981+ if (max_wal_senders < MtmMaxNodes )
1982+ {
1983+ elog (WARNING ,
1984+ "multimaster requires max_wal_senders >= %d (multimaster.max_nodes), " ,
1985+ MtmMaxNodes );
1986+ ok = false;
1987+ }
1988+
1989+ if (max_replication_slots < MtmMaxNodes )
1990+ {
1991+ elog (WARNING ,
1992+ "multimaster requires max_replication_slots >= %d (multimaster.max_nodes), " ,
1993+ MtmMaxNodes );
1994+ ok = false;
1995+ }
1996+
1997+ return ok ;
1998+ }
1999+
19382000void
19392001_PG_init (void )
19402002{
@@ -2274,18 +2336,15 @@ _PG_init(void)
22742336 NULL
22752337 );
22762338
2277- if (DefaultXactIsoLevel != XACT_REPEATABLE_READ ) {
2278- elog (ERROR , "Multimaster requires repeatable read default isolation level" );
2279- }
2280- #if 0
2281- if (synchronous_commit != SYNCHRONOUS_COMMIT_ON ) {
2282- elog (ERROR , "Multimaster requires synchronous commit on" );
2339+ if (!ConfigIsSane ()) {
2340+ elog (ERROR , "Multimaster config is insane, refusing to work" );
22832341 }
2284- #endif
22852342
2343+ /* This will also perform some checks on connection strings */
22862344 MtmSplitConnStrs ();
2345+
22872346 MtmStartReceivers ();
2288-
2347+
22892348 /*
22902349 * Request additional shared resources. (These are no-ops if we're not in
22912350 * the postmaster process.) We'll allocate or attach to the shared
0 commit comments