Skip to content

Commit 8bb0954

Browse files
Merge pull request #15962 from rabbitmq/qq-segment-max-size-bytes-config
Improve quorum queue Ra system configurability
2 parents 78234f0 + 42927f0 commit 8bb0954

4 files changed

Lines changed: 178 additions & 16 deletions

File tree

deps/rabbit/docs/rabbitmq.conf.example

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,46 @@
487487
## when there are multiple publishers sending to the same quorum queue.
488488
# quorum_queue.commands_soft_limit = 32
489489

490+
## Enables or disables WAL checksums for quorum queues.
491+
##
492+
# quorum_queue.wal_compute_checksums = true
493+
494+
## Enables or disables segment file checksums for quorum queues.
495+
##
496+
# quorum_queue.segment_compute_checksums = true
497+
498+
## Sets the maximum batch size for append entries RPC for quorum queues.
499+
##
500+
# quorum_queue.max_append_entries_rpc_batch_size = 16
501+
502+
## Enables or disables memory table compression for quorum queues.
503+
##
504+
# quorum_queue.compress_mem_tables = true
505+
506+
## Sets the maximum size of Raft log segment files for quorum queues.
507+
##
508+
# quorum_queue.segment_max_size_bytes = 64000000
509+
510+
## Sets the maximum number of entries per Raft log segment for quorum queues.
511+
##
512+
# quorum_queue.segment_max_entries = 4096
513+
514+
## Sets the maximum size of the Write-Ahead Log (WAL) for quorum queues.
515+
##
516+
# quorum_queue.wal_max_size_bytes = 536870912
517+
518+
## Sets the maximum number of entries in the Write-Ahead Log (WAL) for quorum queues.
519+
##
520+
# quorum_queue.wal_max_entries = 500000
521+
522+
## Sets the maximum batch size for WAL writes for quorum queues.
523+
##
524+
# quorum_queue.wal_max_batch_size = 4096
525+
526+
## Sets the maximum size of snapshot chunks for quorum queues.
527+
##
528+
# quorum_queue.snapshot_chunk_size = 1000000
529+
490530
## Changes classic queue storage implementation version.
491531
## As of 4.0.0, version 2 is the default and this is a forward compatibility setting,
492532
## that is, it will be useful when a new version is developed.

deps/rabbit/priv/schema/rabbit.schema

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2754,6 +2754,53 @@ end}.
27542754
{validators, ["non_zero_positive_integer"]}
27552755
]}.
27562756

2757+
{mapping, "quorum_queue.wal_compute_checksums", "rabbit.quorum_wal_compute_checksums", [
2758+
{datatype, {enum, [true, false]}}
2759+
]}.
2760+
2761+
{mapping, "quorum_queue.segment_compute_checksums", "rabbit.quorum_segment_compute_checksums", [
2762+
{datatype, {enum, [true, false]}}
2763+
]}.
2764+
2765+
{mapping, "quorum_queue.max_append_entries_rpc_batch_size", "rabbit.quorum_max_append_entries_rpc_batch_size", [
2766+
{datatype, integer},
2767+
{validators, ["non_zero_positive_integer"]}
2768+
]}.
2769+
2770+
{mapping, "quorum_queue.compress_mem_tables", "rabbit.quorum_compress_mem_tables", [
2771+
{datatype, {enum, [true, false]}}
2772+
]}.
2773+
2774+
{mapping, "quorum_queue.segment_max_size_bytes", "rabbit.quorum_segment_max_size_bytes", [
2775+
{datatype, integer},
2776+
{validators, ["non_zero_positive_integer"]}
2777+
]}.
2778+
2779+
{mapping, "quorum_queue.segment_max_entries", "rabbit.quorum_segment_max_entries", [
2780+
{datatype, integer},
2781+
{validators, ["non_zero_positive_integer", "positive_16_bit_unsigned_integer"]}
2782+
]}.
2783+
2784+
{mapping, "quorum_queue.wal_max_size_bytes", "rabbit.quorum_wal_max_size_bytes", [
2785+
{datatype, integer},
2786+
{validators, ["non_zero_positive_integer"]}
2787+
]}.
2788+
2789+
{mapping, "quorum_queue.wal_max_entries", "rabbit.quorum_wal_max_entries", [
2790+
{datatype, integer},
2791+
{validators, ["non_zero_positive_integer"]}
2792+
]}.
2793+
2794+
{mapping, "quorum_queue.wal_max_batch_size", "rabbit.quorum_wal_max_batch_size", [
2795+
{datatype, integer},
2796+
{validators, ["non_zero_positive_integer"]}
2797+
]}.
2798+
2799+
{mapping, "quorum_queue.snapshot_chunk_size", "rabbit.quorum_snapshot_chunk_size", [
2800+
{datatype, integer},
2801+
{validators, ["non_zero_positive_integer"]}
2802+
]}.
2803+
27572804
%%
27582805
%% Quorum Queue membership reconciliation
27592806
%%

deps/rabbit/src/rabbit_ra_systems.erl

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424

2525
-define(COORD_WAL_MAX_SIZE_B, 64_000_000).
2626
-define(QUORUM_AER_MAX_RPC_SIZE, 16).
27-
-define(QUORUM_DEFAULT_WAL_MAX_ENTRIES, 500_000).
27+
-define(QUORUM_DEFAULT_WAL_MAX_SIZE_B, 536_870_912).
28+
-define(QUORUM_DEFAULT_WAL_MAX_BATCH_SIZE, 4096).
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).
@@ -112,18 +113,13 @@ ensure_ra_system_started(RaSystem) ->
112113

113114
-spec get_config(ra_system_name()) -> ra_system:config().
114115
get_config(quorum_queues = RaSystem) ->
115-
DefaultConfig = get_default_config(),
116+
DefaultConfig = ra_system:default_config(),
116117
Checksums = application:get_env(rabbit, quorum_compute_checksums, true),
117118
WalChecksums = application:get_env(rabbit, quorum_wal_compute_checksums, Checksums),
118119
SegmentChecksums = application:get_env(rabbit, quorum_segment_compute_checksums,
119120
Checksums),
120-
WalMaxEntries = case DefaultConfig of
121-
#{wal_max_entries := MaxEntries}
122-
when is_integer(MaxEntries) ->
123-
MaxEntries;
124-
_ ->
125-
?QUORUM_DEFAULT_WAL_MAX_ENTRIES
126-
end,
121+
WalMaxEntries = application:get_env(rabbit, quorum_wal_max_entries,
122+
maps:get(wal_max_entries, DefaultConfig)),
127123
AERBatchSize = application:get_env(rabbit, quorum_max_append_entries_rpc_batch_size,
128124
?QUORUM_AER_MAX_RPC_SIZE),
129125
CompressMemTables = application:get_env(rabbit, quorum_compress_mem_tables, true),
@@ -133,6 +129,16 @@ get_config(quorum_queues = RaSystem) ->
133129
_ ->
134130
?MIN_BIN_VHEAP_SIZE_DEFAULT
135131
end,
132+
SegmentMaxSizeBytes = application:get_env(rabbit, quorum_segment_max_size_bytes,
133+
maps:get(segment_max_size_bytes, DefaultConfig)),
134+
SegmentMaxEntries = application:get_env(rabbit, quorum_segment_max_entries,
135+
maps:get(segment_max_entries, DefaultConfig)),
136+
WalMaxSizeBytes = application:get_env(rabbit, quorum_wal_max_size_bytes,
137+
?QUORUM_DEFAULT_WAL_MAX_SIZE_B),
138+
WalMaxBatchSize = application:get_env(rabbit, quorum_wal_max_batch_size,
139+
?QUORUM_DEFAULT_WAL_MAX_BATCH_SIZE),
140+
SnapshotChunkSize = application:get_env(rabbit, quorum_snapshot_chunk_size,
141+
maps:get(snapshot_chunk_size, DefaultConfig)),
136142

137143
DefaultConfig#{name => RaSystem,
138144
wal_min_bin_vheap_size => MinBinVheapSize,
@@ -142,10 +148,15 @@ get_config(quorum_queues = RaSystem) ->
142148
wal_max_entries => WalMaxEntries,
143149
segment_compute_checksums => SegmentChecksums,
144150
compress_mem_tables => CompressMemTables,
151+
segment_max_size_bytes => SegmentMaxSizeBytes,
152+
segment_max_entries => SegmentMaxEntries,
153+
wal_max_size_bytes => WalMaxSizeBytes,
154+
wal_max_batch_size => WalMaxBatchSize,
155+
snapshot_chunk_size => SnapshotChunkSize,
145156
server_recovery_strategy => {rabbit_quorum_queue,
146157
system_recover, []}};
147158
get_config(coordination = RaSystem) ->
148-
DefaultConfig = get_default_config(),
159+
DefaultConfig = ra_system:default_config(),
149160
CoordDataDir = filename:join(
150161
[rabbit:data_dir(), "coordination", node()]),
151162
DefaultConfig#{name => RaSystem,
@@ -154,13 +165,7 @@ get_config(coordination = RaSystem) ->
154165
wal_max_size_bytes => ?COORD_WAL_MAX_SIZE_B,
155166
names => ra_system:derive_names(RaSystem)}.
156167

157-
-spec get_default_config() -> ra_system:config().
158-
159-
get_default_config() ->
160-
ra_system:default_config().
161-
162168
-spec ensure_stopped() -> ok | no_return().
163-
164169
ensure_stopped() ->
165170
?LOG_DEBUG(
166171
"Stopping Ra systems",

deps/rabbit/test/config_schema_SUITE_data/rabbit.snippets

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,76 @@ credential_validator.regexp = ^abc\\d+",
11601160
]}],
11611161
[]},
11621162

1163+
{quorum_queue_wal_compute_checksums,
1164+
"quorum_queue.wal_compute_checksums = true",
1165+
[{rabbit, [
1166+
{quorum_wal_compute_checksums, true}
1167+
]}],
1168+
[]},
1169+
1170+
{quorum_queue_segment_compute_checksums,
1171+
"quorum_queue.segment_compute_checksums = true",
1172+
[{rabbit, [
1173+
{quorum_segment_compute_checksums, true}
1174+
]}],
1175+
[]},
1176+
1177+
{quorum_queue_max_append_entries_rpc_batch_size,
1178+
"quorum_queue.max_append_entries_rpc_batch_size = 16",
1179+
[{rabbit, [
1180+
{quorum_max_append_entries_rpc_batch_size, 16}
1181+
]}],
1182+
[]},
1183+
1184+
{quorum_queue_compress_mem_tables,
1185+
"quorum_queue.compress_mem_tables = true",
1186+
[{rabbit, [
1187+
{quorum_compress_mem_tables, true}
1188+
]}],
1189+
[]},
1190+
1191+
{quorum_queue_segment_max_size_bytes,
1192+
"quorum_queue.segment_max_size_bytes = 64000000",
1193+
[{rabbit, [
1194+
{quorum_segment_max_size_bytes, 64000000}
1195+
]}],
1196+
[]},
1197+
1198+
{quorum_queue_segment_max_entries,
1199+
"quorum_queue.segment_max_entries = 4096",
1200+
[{rabbit, [
1201+
{quorum_segment_max_entries, 4096}
1202+
]}],
1203+
[]},
1204+
1205+
{quorum_queue_wal_max_size_bytes,
1206+
"quorum_queue.wal_max_size_bytes = 536870912",
1207+
[{rabbit, [
1208+
{quorum_wal_max_size_bytes, 536870912}
1209+
]}],
1210+
[]},
1211+
1212+
{quorum_queue_wal_max_entries,
1213+
"quorum_queue.wal_max_entries = 500000",
1214+
[{rabbit, [
1215+
{quorum_wal_max_entries, 500000}
1216+
]}],
1217+
[]},
1218+
1219+
{quorum_queue_wal_max_batch_size,
1220+
"quorum_queue.wal_max_batch_size = 4096",
1221+
[{rabbit, [
1222+
{quorum_wal_max_batch_size, 4096}
1223+
]}],
1224+
[]},
1225+
1226+
{quorum_queue_snapshot_chunk_size,
1227+
"quorum_queue.snapshot_chunk_size = 1000000",
1228+
[{rabbit, [
1229+
{quorum_snapshot_chunk_size, 1000000}
1230+
]}],
1231+
[]},
1232+
11631233
%%
11641234
%% Runtime parameters
11651235
%%

0 commit comments

Comments
 (0)