Skip to content

Commit 6bcbcbd

Browse files
Loïc Hoguinmergify[bot]
authored andcommitted
CQ: Fix a crash when CMQ master changes in mixed environment test
When policies are applied to change a CMQ master, and that master moves from 3.13 to 3.12, this triggers a CQ version change (because it defaults to v2 in 3.13 but v1 in 3.12). which leads to a crash because the files on disk have an index entry for messages that are in memory only. The index entry is only created with CMQs, normal CQs prohibit this behavior. Since we are going to remove CMQs "soon" the solution to fix the crash was to simply ignore the index entry when we know the message is already in memory. (cherry picked from commit 90e871d)
1 parent 64116a9 commit 6bcbcbd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

deps/rabbit/src/rabbit_variable_queue.erl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,11 @@ convert_from_v2_to_v1_loop(QueueName, V1Index0, V2Index0, V2Store0,
11771177
V1Index1b = rabbit_queue_index:publish(MsgId, SeqId, rabbit_msg_store, Props, IsPersistent, infinity, V1Index1a),
11781178
rabbit_queue_index:deliver([SeqId], V1Index1b)
11791179
end,
1180-
{V1Index2, V2Store1}
1180+
{V1Index2, V2Store1};
1181+
%% Ignore messages that are in memory and had an entry written in the index.
1182+
%% @todo Remove this clause some time after CMQs get removed as this will become dead code.
1183+
({undefined, _, memory, _, _}, {V1Index1, V2Store1}) ->
1184+
{V1Index1, V2Store1}
11811185
end, {V1Index0, V2Store0}, Messages),
11821186
%% Flush to disk to avoid keeping too much in memory between segments.
11831187
V1Index = rabbit_queue_index:flush(V1Index3),

0 commit comments

Comments
 (0)