@@ -1935,6 +1935,68 @@ static void MtmSplitConnStrs(void)
1935
1935
pfree (copy );
1936
1936
}
1937
1937
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
+
1938
2000
void
1939
2001
_PG_init (void )
1940
2002
{
@@ -2274,18 +2336,15 @@ _PG_init(void)
2274
2336
NULL
2275
2337
);
2276
2338
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" );
2283
2341
}
2284
- #endif
2285
2342
2343
+ /* This will also perform some checks on connection strings */
2286
2344
MtmSplitConnStrs ();
2345
+
2287
2346
MtmStartReceivers ();
2288
-
2347
+
2289
2348
/*
2290
2349
* Request additional shared resources. (These are no-ops if we're not in
2291
2350
* the postmaster process.) We'll allocate or attach to the shared
0 commit comments