Skip to content

Commit

Permalink
Reduce default maximum message size to 16MB
Browse files Browse the repository at this point in the history
  • Loading branch information
dcorbacho committed Jun 14, 2024
1 parent 0f00374 commit d6f9533
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
4 changes: 2 additions & 2 deletions deps/rabbit/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ _APP_ENV = """[
{default_consumer_prefetch, {false, 0}},
%% interval at which the channel can perform periodic actions
{channel_tick_interval, 60000},
%% Default max message size is 128 MB
{max_message_size, 134217728},
%% Default max message size is 16 MB
{max_message_size, 16777216},
%% Socket writer will run GC every 1 GB of outgoing data
{writer_gc_threshold, 1000000000},
%% interval at which connection/channel tracking executes post operations
Expand Down
4 changes: 2 additions & 2 deletions deps/rabbit/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ define PROJECT_ENV
{default_consumer_prefetch, {false, 0}},
%% interval at which the channel can perform periodic actions
{channel_tick_interval, 60000},
%% Default max message size is 128 MB
{max_message_size, 134217728},
%% Default max message size is 16 MB
{max_message_size, 16777216},
%% Socket writer will run GC every 1 GB of outgoing data
{writer_gc_threshold, 1000000000},
%% interval at which connection/channel tracking executes post operations
Expand Down
1 change: 1 addition & 0 deletions deps/rabbit/src/rabbit.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1727,6 +1727,7 @@ persist_static_configuration() ->
_ ->
?MAX_MSG_SIZE
end,
rabbit_log:warning("TRACEPUT max_message_size ~p", [MaxMsgSize]),
ok = persistent_term:put(max_message_size, MaxMsgSize).

persist_static_configuration(Params) ->
Expand Down
26 changes: 21 additions & 5 deletions deps/rabbit/test/message_size_limit_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@

all() ->
[
{group, tests}
{group, tests},
{group, default}
].

groups() ->
[
{tests, [], [
max_message_size
]}
]},
{default, [], [
default_max_message_size
]}
].

suite() ->
Expand Down Expand Up @@ -70,9 +74,6 @@ max_message_size(Config) ->
Binary6M = gen_binary_mb(6),
Binary10M = gen_binary_mb(10),

Size2Mb = 1024 * 1024 * 2,
Size2Mb = byte_size(Binary2M),

ok = rabbit_ct_broker_helpers:rpc(Config, persistent_term, put, [max_message_size, 1024 * 1024 * 3]),

{_, Ch} = rabbit_ct_client_helpers:open_connection_and_channel(Config, 0),
Expand Down Expand Up @@ -104,6 +105,21 @@ max_message_size(Config) ->
amqp_channel:call(Ch1, #'basic.publish'{routing_key = <<"none">>}, #amqp_msg{payload = Binary10M}),
assert_channel_fail_max_size(Ch1, Monitor1).

default_max_message_size(Config) ->
Binary15M = gen_binary_mb(15),
Binary17M = gen_binary_mb(20),

{_, Ch} = rabbit_ct_client_helpers:open_connection_and_channel(Config, 0),

%% Binary is within the default max size limit of 16MB
amqp_channel:call(Ch, #'basic.publish'{routing_key = <<"none">>}, #amqp_msg{payload = Binary15M}),
%% The channel process is alive
assert_channel_alive(Ch),

Monitor = monitor(process, Ch),
amqp_channel:call(Ch, #'basic.publish'{routing_key = <<"none">>}, #amqp_msg{payload = Binary17M}),
assert_channel_fail_max_size(Ch, Monitor).

%% -------------------------------------------------------------------
%% Implementation
%% -------------------------------------------------------------------
Expand Down

0 comments on commit d6f9533

Please sign in to comment.