Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4c36f2e

Browse files
committed
Add config sanity check in mmts.
1 parent 663c11a commit 4c36f2e

File tree

2 files changed

+70
-10
lines changed

2 files changed

+70
-10
lines changed

contrib/mmts/multimaster.c

Lines changed: 67 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1926,6 +1926,68 @@ static void MtmSplitConnStrs(void)
19261926
pfree(copy);
19271927
}
19281928

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+
19291991
void
19301992
_PG_init(void)
19311993
{
@@ -2265,18 +2327,15 @@ _PG_init(void)
22652327
NULL
22662328
);
22672329

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");
22742332
}
2275-
#endif
22762333

2334+
/* This will also perform some checks on connection strings */
22772335
MtmSplitConnStrs();
2336+
22782337
MtmStartReceivers();
2279-
2338+
22802339
/*
22812340
* Request additional shared resources. (These are no-ops if we're not in
22822341
* the postmaster process.) We'll allocate or attach to the shared

contrib/mmts/tests/daemons.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,13 @@ func postgres(bin string, datadir string, postgresi []string, port int, nodeid i
112112
"-c", "max_connections=200",
113113
"-c", "max_replication_slots=10",
114114
"-c", "max_wal_senders=10",
115-
"-c", "max_worker_processes=100",
116-
"-c", "max_prepared_transactions=200",
115+
"-c", "max_worker_processes=11",
116+
"-c", "max_prepared_transactions=10",
117117
"-c", "default_transaction_isolation=repeatable read",
118118
"-c", "multimaster.conn_strings=" + strings.Join(postgresi, ","),
119119
"-c", "multimaster.node_id=" + strconv.Itoa(nodeid + 1),
120120
"-c", "multimaster.queue_size=52857600",
121+
"-c", "multimaster.max_nodes=3",
121122
"-c", "multimaster.workers=4",
122123
"-c", "multimaster.use_raftable=true",
123124
"-c", "multimaster.ignore_tables_without_pk=1",

0 commit comments

Comments
 (0)