Skip to content

Commit 758fd67

Browse files
Merge branch 'stable'
2 parents 09af3f6 + 5b71eb3 commit 758fd67

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

src/rabbit_variable_queue.erl

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@
273273
msg_store_clients,
274274
durable,
275275
transient_threshold,
276+
qi_embed_msgs_below,
276277

277278
len, %% w/o unacked
278279
bytes, %% w/o unacked
@@ -370,6 +371,7 @@
370371
{any(), binary()}},
371372
durable :: boolean(),
372373
transient_threshold :: non_neg_integer(),
374+
qi_embed_msgs_below :: non_neg_integer(),
373375

374376
len :: non_neg_integer(),
375377
bytes :: non_neg_integer(),
@@ -569,12 +571,13 @@ publish(Msg = #basic_message { is_persistent = IsPersistent, id = MsgId },
569571
MsgProps = #message_properties { needs_confirming = NeedsConfirming },
570572
IsDelivered, _ChPid, _Flow,
571573
State = #vqstate { q1 = Q1, q3 = Q3, q4 = Q4,
572-
next_seq_id = SeqId,
573-
in_counter = InCount,
574-
durable = IsDurable,
575-
unconfirmed = UC }) ->
574+
qi_embed_msgs_below = IndexMaxSize,
575+
next_seq_id = SeqId,
576+
in_counter = InCount,
577+
durable = IsDurable,
578+
unconfirmed = UC }) ->
576579
IsPersistent1 = IsDurable andalso IsPersistent,
577-
MsgStatus = msg_status(IsPersistent1, IsDelivered, SeqId, Msg, MsgProps),
580+
MsgStatus = msg_status(IsPersistent1, IsDelivered, SeqId, Msg, MsgProps, IndexMaxSize),
578581
{MsgStatus1, State1} = maybe_write_to_disk(false, false, MsgStatus, State),
579582
State2 = case ?QUEUE:is_empty(Q3) of
580583
false -> State1 #vqstate { q1 = ?QUEUE:in(m(MsgStatus1), Q1) };
@@ -593,13 +596,14 @@ publish_delivered(Msg = #basic_message { is_persistent = IsPersistent,
593596
MsgProps = #message_properties {
594597
needs_confirming = NeedsConfirming },
595598
_ChPid, _Flow,
596-
State = #vqstate { next_seq_id = SeqId,
597-
out_counter = OutCount,
598-
in_counter = InCount,
599-
durable = IsDurable,
600-
unconfirmed = UC }) ->
599+
State = #vqstate { qi_embed_msgs_below = IndexMaxSize,
600+
next_seq_id = SeqId,
601+
out_counter = OutCount,
602+
in_counter = InCount,
603+
durable = IsDurable,
604+
unconfirmed = UC }) ->
601605
IsPersistent1 = IsDurable andalso IsPersistent,
602-
MsgStatus = msg_status(IsPersistent1, true, SeqId, Msg, MsgProps),
606+
MsgStatus = msg_status(IsPersistent1, true, SeqId, Msg, MsgProps, IndexMaxSize),
603607
{MsgStatus1, State1} = maybe_write_to_disk(false, false, MsgStatus, State),
604608
State2 = record_pending_ack(m(MsgStatus1), State1),
605609
UC1 = gb_sets_maybe_insert(NeedsConfirming, MsgId, UC),
@@ -1029,15 +1033,15 @@ gb_sets_maybe_insert(false, _Val, Set) -> Set;
10291033
gb_sets_maybe_insert(true, Val, Set) -> gb_sets:add(Val, Set).
10301034

10311035
msg_status(IsPersistent, IsDelivered, SeqId,
1032-
Msg = #basic_message {id = MsgId}, MsgProps) ->
1036+
Msg = #basic_message {id = MsgId}, MsgProps, IndexMaxSize) ->
10331037
#msg_status{seq_id = SeqId,
10341038
msg_id = MsgId,
10351039
msg = Msg,
10361040
is_persistent = IsPersistent,
10371041
is_delivered = IsDelivered,
10381042
msg_in_store = false,
10391043
index_on_disk = false,
1040-
persist_to = determine_persist_to(Msg, MsgProps),
1044+
persist_to = determine_persist_to(Msg, MsgProps, IndexMaxSize),
10411045
msg_props = MsgProps}.
10421046

10431047
beta_msg_status({Msg = #basic_message{id = MsgId},
@@ -1198,6 +1202,9 @@ init(IsDurable, IndexState, DeltaCount, DeltaBytes, Terms,
11981202
Now = time_compat:monotonic_time(),
11991203
IoBatchSize = rabbit_misc:get_env(rabbit, msg_store_io_batch_size,
12001204
?IO_BATCH_SIZE),
1205+
1206+
{ok, IndexMaxSize} = application:get_env(
1207+
rabbit, queue_index_embed_msgs_below),
12011208
State = #vqstate {
12021209
q1 = ?QUEUE:new(),
12031210
q2 = ?QUEUE:new(),
@@ -1212,6 +1219,7 @@ init(IsDurable, IndexState, DeltaCount, DeltaBytes, Terms,
12121219
msg_store_clients = {PersistentClient, TransientClient},
12131220
durable = IsDurable,
12141221
transient_threshold = NextSeqId,
1222+
qi_embed_msgs_below = IndexMaxSize,
12151223

12161224
len = DeltaCount1,
12171225
persistent_count = DeltaCount1,
@@ -1469,9 +1477,8 @@ maybe_write_to_disk(ForceMsg, ForceIndex, MsgStatus, State) ->
14691477
determine_persist_to(#basic_message{
14701478
content = #content{properties = Props,
14711479
properties_bin = PropsBin}},
1472-
#message_properties{size = BodySize}) ->
1473-
{ok, IndexMaxSize} = application:get_env(
1474-
rabbit, queue_index_embed_msgs_below),
1480+
#message_properties{size = BodySize},
1481+
IndexMaxSize) ->
14751482
%% The >= is so that you can set the env to 0 and never persist
14761483
%% to the index.
14771484
%%

0 commit comments

Comments
 (0)