diff options
| author | Thuan Duong Ba <thuandb@amazon.com> | 2021-12-08 15:01:52 -0800 |
|---|---|---|
| committer | Thuan Duong-Ba <59986634+thuandb@users.noreply.github.com> | 2021-12-20 17:39:06 -0800 |
| commit | dc6fb24761fa25577f0f69615a51a166f0a38552 (patch) | |
| tree | 6fd2889b3c9ad7c3c65199edb8229db875a54985 | |
| parent | 1ab485b44c5dc3e5a8ceacbc89579ca2cf706faf (diff) | |
| download | rabbitmq-server-git-dc6fb24761fa25577f0f69615a51a166f0a38552.tar.gz | |
minor fix on condition to stop batching when total batch size is large
| -rw-r--r-- | deps/rabbit/src/rabbit_mirror_queue_sync.erl | 4 | ||||
| -rw-r--r-- | deps/rabbit/test/rabbit_mirror_queue_sync_SUITE.erl | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/deps/rabbit/src/rabbit_mirror_queue_sync.erl b/deps/rabbit/src/rabbit_mirror_queue_sync.erl index 0519836902..f7008013dc 100644 --- a/deps/rabbit/src/rabbit_mirror_queue_sync.erl +++ b/deps/rabbit/src/rabbit_mirror_queue_sync.erl @@ -118,7 +118,7 @@ maybe_master_batch_send({_, _, _, {Curr, _Len}, _}, BatchSize) when Curr rem BatchSize =:= 0 -> true; maybe_master_batch_send({_, _, {TotalBytes, _, SyncThroughput}, {_Curr, _Len}, _}, _BatchSize) - when TotalBytes >= SyncThroughput -> + when TotalBytes > SyncThroughput -> true; maybe_master_batch_send(_Acc, _BatchSize) -> false. @@ -131,7 +131,7 @@ bq_fold(FoldFun, FoldAcc, Args, BQ, BQS) -> end. append_to_acc(Msg, MsgProps, Unacked, {Batch, I, {_, _, 0}, {Curr, Len}, T}) -> - {[{Msg, MsgProps, Unacked} | Batch], I, {-1, 0, 0}, {Curr + 1, Len}, T}; + {[{Msg, MsgProps, Unacked} | Batch], I, {0, 0, 0}, {Curr + 1, Len}, T}; append_to_acc(Msg, MsgProps, Unacked, {Batch, I, {TotalBytes, LastCheck, SyncThroughput}, {Curr, Len}, T}) -> {[{Msg, MsgProps, Unacked} | Batch], I, {TotalBytes + rabbit_basic:msg_size(Msg), LastCheck, SyncThroughput}, {Curr + 1, Len}, T}. diff --git a/deps/rabbit/test/rabbit_mirror_queue_sync_SUITE.erl b/deps/rabbit/test/rabbit_mirror_queue_sync_SUITE.erl index f9ce4a99b6..f09edeb9d6 100644 --- a/deps/rabbit/test/rabbit_mirror_queue_sync_SUITE.erl +++ b/deps/rabbit/test/rabbit_mirror_queue_sync_SUITE.erl @@ -73,7 +73,7 @@ append_to_acc(_Config) -> SyncThroughput_0 = 0, FoldAcc1 = {[], 0, {0, erlang:monotonic_time(), SyncThroughput_0}, {0, BQDepth}, erlang:monotonic_time()}, {_, _, {TotalBytes1, _, _}, _, _} = rabbit_mirror_queue_sync:append_to_acc(Msg, {}, false, FoldAcc1), - ?assertEqual(-1, TotalBytes1), %% Skipping calculating TotalBytes for the pending batch as SyncThroughput is 0. + ?assertEqual(0, TotalBytes1), %% Skipping calculating TotalBytes for the pending batch as SyncThroughput is 0. SyncThroughput = 100, FoldAcc2 = {[], 0, {0, erlang:monotonic_time(), SyncThroughput}, {0, BQDepth}, erlang:monotonic_time()}, |
