@@ -1926,6 +1926,68 @@ static void MtmSplitConnStrs(void)
1926
1926
pfree (copy );
1927
1927
}
1928
1928
1929
+ static bool ConfigIsSane (void )
1930
+ {
1931
+ bool ok = true;
1932
+
1933
+ if (DefaultXactIsoLevel != XACT_REPEATABLE_READ )
1934
+ {
1935
+ elog (WARNING , "multimaster requires default_transaction_isolation = 'repeatable read'" );
1936
+ ok = false;
1937
+ }
1938
+
1939
+ if (MtmMaxNodes < 1 )
1940
+ {
1941
+ elog (WARNING , "multimaster requires multimaster.max_nodes > 0" );
1942
+ ok = false;
1943
+ }
1944
+
1945
+ if (max_prepared_xacts < 1 )
1946
+ {
1947
+ elog (WARNING ,
1948
+ "multimaster requires max_prepared_transactions > 0, "
1949
+ "because all transactions are implicitly two-phase" );
1950
+ ok = false;
1951
+ }
1952
+
1953
+ {
1954
+ int workers_required = 2 * MtmMaxNodes + MtmWorkers + 1 ;
1955
+ if (max_worker_processes < workers_required )
1956
+ {
1957
+ elog (WARNING ,
1958
+ "multimaster requires max_worker_processes >= %d" ,
1959
+ workers_required );
1960
+ ok = false;
1961
+ }
1962
+ }
1963
+
1964
+ if (wal_level != WAL_LEVEL_LOGICAL )
1965
+ {
1966
+ elog (WARNING ,
1967
+ "multimaster requires wal_level = 'logical', "
1968
+ "because it is build on top of logical replication" );
1969
+ ok = false;
1970
+ }
1971
+
1972
+ if (max_wal_senders < MtmMaxNodes )
1973
+ {
1974
+ elog (WARNING ,
1975
+ "multimaster requires max_wal_senders >= %d (multimaster.max_nodes), " ,
1976
+ MtmMaxNodes );
1977
+ ok = false;
1978
+ }
1979
+
1980
+ if (max_replication_slots < MtmMaxNodes )
1981
+ {
1982
+ elog (WARNING ,
1983
+ "multimaster requires max_replication_slots >= %d (multimaster.max_nodes), " ,
1984
+ MtmMaxNodes );
1985
+ ok = false;
1986
+ }
1987
+
1988
+ return ok ;
1989
+ }
1990
+
1929
1991
void
1930
1992
_PG_init (void )
1931
1993
{
@@ -2265,18 +2327,15 @@ _PG_init(void)
2265
2327
NULL
2266
2328
);
2267
2329
2268
- if (DefaultXactIsoLevel != XACT_REPEATABLE_READ ) {
2269
- elog (ERROR , "Multimaster requires repeatable read default isolation level" );
2270
- }
2271
- #if 0
2272
- if (synchronous_commit != SYNCHRONOUS_COMMIT_ON ) {
2273
- elog (ERROR , "Multimaster requires synchronous commit on" );
2330
+ if (!ConfigIsSane ()) {
2331
+ elog (ERROR , "Multimaster config is insane, refusing to work" );
2274
2332
}
2275
- #endif
2276
2333
2334
+ /* This will also perform some checks on connection strings */
2277
2335
MtmSplitConnStrs ();
2336
+
2278
2337
MtmStartReceivers ();
2279
-
2338
+
2280
2339
/*
2281
2340
* Request additional shared resources. (These are no-ops if we're not in
2282
2341
* the postmaster process.) We'll allocate or attach to the shared
0 commit comments