Skip to content

Commit d427e1d

Browse files
Merge pull request #2149 from rabbitmq/rabbitmq-server-2140
Make a bunch of Ra settings configurable rabbitmq.conf (cherry picked from commit 87f1b31)
1 parent 42987b9 commit d427e1d

File tree

4 files changed

+113
-2
lines changed

4 files changed

+113
-2
lines changed

docs/rabbitmq.conf.example

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,18 @@
441441
##
442442
# collect_statistics_interval = 5000
443443

444+
##
445+
## Ra Settings
446+
## =====================
447+
##
448+
## NB: changing these on a node with existing data directory
449+
## can lead to DATA LOSS.
450+
##
451+
# raft.segment_max_entries = 65535
452+
# raft.wal_max_size_bytes = 1048576
453+
# raft.wal_max_batch_size = 32768
454+
# raft.snapshot_chunk_size = 1000000
455+
444456
##
445457
## Misc/Advanced Options
446458
## =====================

priv/schema/rabbit.schema

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,67 @@ end}.
15221522
end
15231523
}.
15241524

1525+
%%
1526+
%% Ra
1527+
%%
1528+
1529+
{mapping, "raft.segment_max_entries", "ra.segment_max_entries", [
1530+
{datatype, integer},
1531+
{validators, ["non_zero_positive_integer"]}
1532+
]}.
1533+
1534+
{translation, "ra.segment_max_entries",
1535+
fun(Conf) ->
1536+
case cuttlefish:conf_get("raft.segment_max_entries", Conf, undefined) of
1537+
undefined -> cuttlefish:unset();
1538+
Val -> Val
1539+
end
1540+
end
1541+
}.
1542+
1543+
{mapping, "raft.wal_max_size_bytes", "ra.wal_max_size_bytes", [
1544+
{datatype, integer},
1545+
{validators, ["non_zero_positive_integer"]}
1546+
]}.
1547+
1548+
{translation, "ra.wal_max_size_bytes",
1549+
fun(Conf) ->
1550+
case cuttlefish:conf_get("raft.wal_max_size_bytes", Conf, undefined) of
1551+
undefined -> cuttlefish:unset();
1552+
Val -> Val
1553+
end
1554+
end
1555+
}.
1556+
1557+
{mapping, "raft.wal_max_batch_size", "ra.wal_max_batch_size", [
1558+
{datatype, integer},
1559+
{validators, ["non_zero_positive_integer"]}
1560+
]}.
1561+
1562+
{translation, "ra.wal_max_batch_size",
1563+
fun(Conf) ->
1564+
case cuttlefish:conf_get("raft.wal_max_batch_size", Conf, undefined) of
1565+
undefined -> cuttlefish:unset();
1566+
Val -> Val
1567+
end
1568+
end
1569+
}.
1570+
1571+
{mapping, "raft.snapshot_chunk_size", "ra.snapshot_chunk_size", [
1572+
{datatype, integer},
1573+
{validators, ["non_zero_positive_integer"]}
1574+
]}.
1575+
1576+
{translation, "ra.snapshot_chunk_size",
1577+
fun(Conf) ->
1578+
case cuttlefish:conf_get("raft.snapshot_chunk_size", Conf, undefined) of
1579+
undefined -> cuttlefish:unset();
1580+
Val -> Val
1581+
end
1582+
end
1583+
}.
1584+
1585+
15251586
% ===============================
15261587
% Validators
15271588
% ===============================

src/rabbit.erl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,12 @@ start_loaded_apps(Apps, RestartTypes) ->
541541
%% default OTP logger
542542
application:set_env(ra, logger_module, rabbit_log_ra_shim),
543543
%% use a larger segments size for queues
544-
application:set_env(ra, segment_max_entries, 32768),
544+
case application:get_env(ra, segment_max_entries) of
545+
undefined ->
546+
application:set_env(ra, segment_max_entries, 32768);
547+
_ ->
548+
ok
549+
end,
545550
case application:get_env(ra, wal_max_size_bytes) of
546551
undefined ->
547552
application:set_env(ra, wal_max_size_bytes, 536870912); %% 5 * 2 ^ 20

test/config_schema_SUITE_data/rabbit.snippets

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,5 +638,38 @@ credential_validator.regexp = ^abc\\d+",
638638
{cacertfile,"test/config_schema_SUITE_data/certs/cacert.pem"},
639639
{certfile,"test/config_schema_SUITE_data/certs/cert.pem"},
640640
{keyfile,"test/config_schema_SUITE_data/certs/key.pem"}]}}]}],
641-
[]}
641+
[]},
642+
643+
%%
644+
%% Raft
645+
%%
646+
647+
{raft_segment_max_entries,
648+
"raft.segment_max_entries = 65535",
649+
[{ra, [
650+
{segment_max_entries, 65535}
651+
]}],
652+
[]},
653+
654+
{raft_wal_max_size_bytes,
655+
"raft.wal_max_size_bytes = 1048576",
656+
[{ra, [
657+
{wal_max_size_bytes, 1048576}
658+
]}],
659+
[]},
660+
661+
{raft_wal_max_batch_size,
662+
"raft.wal_max_batch_size = 32768",
663+
[{ra, [
664+
{wal_max_batch_size, 32768}
665+
]}],
666+
[]},
667+
668+
{raft_snapshot_chunk_size,
669+
"raft.snapshot_chunk_size = 1000000",
670+
[{ra, [
671+
{snapshot_chunk_size, 1000000}
672+
]}],
673+
[]}
674+
642675
].

0 commit comments

Comments
 (0)