Skip to content

Commit 3b4492f

Browse files
committed
Make Ra segment_max_size_bytes configurable for quorum queues
Add support for configuring Ra's segment_max_size_bytes parameter via rabbitmq.conf as raft.segment_max_size_bytes. This allows operators to control the maximum size of Raft log segment files for quorum queues. The configuration: - Maps raft.segment_max_size_bytes in rabbitmq.conf to rabbit.quorum_segment_max_size_bytes in the application environment - Defaults to Ra's built-in default of 64 MB when not configured - Is explicitly applied to the quorum_queues Ra system configuration for transparency and maintainability Also add a macro QUORUM_DEFAULT_SEGMENT_MAX_SIZE_B to align with Ra's default value.
1 parent 46431b4 commit 3b4492f

4 files changed

Lines changed: 26 additions & 0 deletions

File tree

deps/rabbit/docs/rabbitmq.conf.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,7 @@
737737
## These set the defaults that quorum queues, streams, Khepri, and other Raft-based features use.
738738
##
739739
# raft.segment_max_entries = 65536
740+
# raft.segment_max_size_bytes = 64000000
740741
# raft.wal_max_size_bytes = 1048576
741742
# raft.wal_max_batch_size = 4096
742743
# raft.snapshot_chunk_size = 1000000

deps/rabbit/priv/schema/rabbit.schema

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2550,6 +2550,20 @@ end}.
25502550
end
25512551
}.
25522552

2553+
{mapping, "raft.segment_max_size_bytes", "rabbit.quorum_segment_max_size_bytes", [
2554+
{datatype, integer},
2555+
{validators, ["non_zero_positive_integer"]}
2556+
]}.
2557+
2558+
{translation, "rabbit.quorum_segment_max_size_bytes",
2559+
fun(Conf) ->
2560+
case cuttlefish:conf_get("raft.segment_max_size_bytes", Conf, undefined) of
2561+
undefined -> cuttlefish:unset();
2562+
Val -> Val
2563+
end
2564+
end
2565+
}.
2566+
25532567
{mapping, "raft.wal_max_size_bytes", "ra.wal_max_size_bytes", [
25542568
{datatype, integer},
25552569
{validators, ["non_zero_positive_integer"]}

deps/rabbit/src/rabbit_ra_systems.erl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
-define(COORD_WAL_MAX_SIZE_B, 64_000_000).
2626
-define(QUORUM_AER_MAX_RPC_SIZE, 16).
2727
-define(QUORUM_DEFAULT_WAL_MAX_ENTRIES, 500_000).
28+
-define(QUORUM_DEFAULT_SEGMENT_MAX_SIZE_B, 64_000_000).
2829
%% the default min bin vheap value in OTP 26
2930
-define(MIN_BIN_VHEAP_SIZE_DEFAULT, 46422).
3031
-define(MIN_BIN_VHEAP_SIZE_MULT, 64).
@@ -133,6 +134,8 @@ get_config(quorum_queues = RaSystem) ->
133134
_ ->
134135
?MIN_BIN_VHEAP_SIZE_DEFAULT
135136
end,
137+
SegmentMaxSizeBytes = application:get_env(rabbit, quorum_segment_max_size_bytes,
138+
?QUORUM_DEFAULT_SEGMENT_MAX_SIZE_B),
136139

137140
DefaultConfig#{name => RaSystem,
138141
wal_min_bin_vheap_size => MinBinVheapSize,
@@ -142,6 +145,7 @@ get_config(quorum_queues = RaSystem) ->
142145
wal_max_entries => WalMaxEntries,
143146
segment_compute_checksums => SegmentChecksums,
144147
compress_mem_tables => CompressMemTables,
148+
segment_max_size_bytes => SegmentMaxSizeBytes,
145149
server_recovery_strategy => {rabbit_quorum_queue,
146150
system_recover, []}};
147151
get_config(coordination = RaSystem) ->

deps/rabbit/test/config_schema_SUITE_data/rabbit.snippets

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,13 @@ credential_validator.regexp = ^abc\\d+",
10711071
]}],
10721072
[]},
10731073

1074+
{raft_segment_max_size_bytes,
1075+
"raft.segment_max_size_bytes = 64000000",
1076+
[{rabbit, [
1077+
{quorum_segment_max_size_bytes, 64000000}
1078+
]}],
1079+
[]},
1080+
10741081
{raft_wal_max_size_bytes,
10751082
"raft.wal_max_size_bytes = 1048576",
10761083
[{ra, [

0 commit comments

Comments
 (0)