Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QQ: introduce new machine version (2) #3121

Merged
merged 97 commits into from Mar 8, 2022
Merged

QQ: introduce new machine version (2) #3121

merged 97 commits into from Mar 8, 2022

Conversation

kjnilsson
Copy link
Contributor

@kjnilsson kjnilsson commented Jun 18, 2021

@kjnilsson kjnilsson force-pushed the quorum-queues-v2 branch 2 times, most recently from f9b2b8a to e804229 Compare July 20, 2021 16:17
@ansd ansd force-pushed the quorum-queues-v2 branch 5 times, most recently from 15c633a to 5ebc7f5 Compare November 8, 2021 17:09
@ansd ansd force-pushed the quorum-queues-v2 branch 7 times, most recently from 9dddc0f to 1b2898e Compare November 16, 2021 10:17
@ansd ansd force-pushed the quorum-queues-v2 branch 3 times, most recently from 329ba51 to 1239d28 Compare November 22, 2021 12:20
@ansd ansd force-pushed the quorum-queues-v2 branch 8 times, most recently from dbfacc0 to a7aaa5c Compare November 30, 2021 15:41
@ansd ansd force-pushed the quorum-queues-v2 branch 2 times, most recently from 52ce0cf to d15bf6d Compare December 3, 2021 10:21
@kjnilsson
Copy link
Contributor Author

kjnilsson commented Dec 3, 2021

https://github.com/rabbitmq/rabbitmq-server/tree/qq-resend-protocol-refactor

Some work around repeated requeues and resend protocol is in this branch and will be integrated to this branch in time.

Save per-message memory for dead-lettered messages by

1. removing all headers that are not needed anymore once the message
   got dead-lettered (delivery_count and expiry), and
2. saving 1 byte for every lqueue element of the discards queue by using
   an improper list instead of tuple to store {Reason, Message}.

In total, this will save 9 bytes per dead-lettered message:
```
1> erts_debug:size({expired, #{delivery_count => 2, size => 3}}).
11
2> erts_debug:size([expired | 3]).
2
```

Many messages can pile up in the discards queue if target queues do not
confirm messages fast enough or not at all.
instead of ?INDEX_MSG and ?DISK_MSG macros
because from now on there will be only disk messages.

This makes the code more readable.
Decrease memory usage by 6 bytes per message if per-message or per-queue
message TTL is set:

1> erts_debug:size(#{size => 1, expiry => 1000}).
8
2> erts_debug:size([1|1000]).
2

While we could always use a record for the header,
we do want the flexibility of a map.
@ansd ansd force-pushed the quorum-queues-v2 branch 2 times, most recently from 3b4d8a3 to c44ea79 Compare February 28, 2022 17:14
@ansd ansd marked this pull request as ready for review February 28, 2022 17:31
ansd added 7 commits March 1, 2022 10:28
since they do not exist anymore
because at-least-once dead-lettered messages are arguably consumer
messages which should not be purged.

According to the AMQP 0.9.1 purge spec:
"This method removes all messages from a queue which are not awaiting
acknowledgment."

At-least-once dead-lettered messages are awaiting acks from target
queues.
1. If all messages in the queue are either in 'messages' or 'returns',
   (i.e. no message currently checked out to consumers) we can directly
   empty the index.
2. Even if there are consumers, there is no need to delete indexes from
   the 'messages' queue because we only append to the index once we move
   a message out of the 'messages' queue.
3. Use lqueue:fold/3 instead of lists:foldl/3 and lqueue:to_list/1
1. A Raft index in ?MSG(RaftIndex, Header) can be 'undefined' if it
was a prefix message in v1. Therefore do not use is_integer(RaftIndex)
guards. Instead, expect and handle RaftIndex=undefined correctly.

2. The total number of messages did not include any checked out messages
after the conversion.
because at-least-once dead-lettering and therefore process
rabbit_fifo_dlx_sup does not exist in 3.9.

Once the new base version in mixed version tests becomes 3.10
(base version is 3.9 as of March 2022), we can revert this commit.
@ansd ansd force-pushed the quorum-queues-v2 branch 4 times, most recently from 68f1217 to 7aa7453 Compare March 1, 2022 11:58
@ansd
Copy link
Member

ansd commented Mar 1, 2022

Docs in rabbitmq/rabbitmq-website#1299

Before this commit, when a quorum queue has only expired messages, but the
timer hasn't expired them yet, and a basic.get tries to dequeue a message
the following error occurred:

{{badmatch,
     {nochange,true,
         {rabbit_fifo, ...},
         [{mod_call,rabbit_global_counters,
              messages_dead_lettered,
              [expired,rabbit_quorum_queue,disabled,1]}]}},
 [{rabbit_fifo,apply,3,[{file,"rabbit_fifo.erl"},{line,387}]},
@kjnilsson kjnilsson merged commit 4b19360 into master Mar 8, 2022
michaelklishin added a commit that referenced this pull request Mar 8, 2022
QQ: introduce new machine version (2) (backport #3121)
@ansd ansd deleted the quorum-queues-v2 branch March 28, 2022 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants