Skip to content

v2.11.0

Choose a tag to compare

@alice-viola alice-viola released this 27 Nov 09:25
· 60 commits to master since this release

Queen MQ 2.11.0: the image is ghcr.io/queen-mq/queen:2.11.0 (linux/amd64 and linux/arm64), and :latest points at it. The clients stay at their versions and talk to 2.11.0 as to 2.10.0: the JavaScript client at 2.9.2, the PHP client at 2.10.0 with supervisor 0.10.0, the Python, Go, Rust and C++ clients at 2.9.0, queen-protocol at 1.7.0, queenctl at 2.7.1. Jepsen ran the whole suite, 568 tests, on 2.11.0-rc.1: all valid.

Upgrading from 2.10.x: a rolling restart. 2.11.0 keeps the data format of 2.10.0 (cluster
version 8), and nodes of the two releases replicate to each other while the roll runs. The clients
stay where they are: the JavaScript client at 2.9.2, the PHP client at 2.10.0 with supervisor
0.10.0, the Python, Go, Rust and C++ clients at 2.9.0, queen-protocol at 1.7.0 and queenctl at
2.7.1. The JavaScript, Python and Rust packages changed only their descriptions (the new name), not
their code, and every client talks to a 2.11.0 broker as to 2.10.0. Jepsen ran the whole suite, 568
tests, on 2.11.0-rc.1 (04541a304), and all were valid; what 2.11.0 adds to it (the one timers
read, the partition counts in Prometheus, the console) puts no new command in the log.

Server: an idle partition leaves the leader's memory on time, however many partitions came
before it.
The leader keeps a small record for each consumer group's partition and drops it once
the partition has held nothing for QUEEN_CONSUME_IDLE_UNLOAD_S (600 s). Until now a background
pass found those records by walking every partition id from the oldest live partition to the
newest one ever created, deleted ones included, one step per consumer group for each id. Ids are
never reused, so a broker that keeps creating partitions (one per chat, trace or reservation) made
that pass longer every day: with 196 consumer groups it walked about 1,000 ids a second, and idle
records stayed in memory for hours past their window (a production leader held 117,000 of them).
Now a record that goes quiet is filed under the end of its window, in a list each shard keeps in
10 ms slots, and the clock work drops it at the first tick after that time, unless it got work in
between. The cost is one entry per record that goes quiet, whatever the number of partitions,
groups or ids ever used, and an ack files its record without reading the partition: the partition
is checked once, when the window ends. The clock work takes at most 1,024 due records from a shard
per tick, so a new leader whose idle windows all end together never holds a shard's lock for long.
Nothing changes in what a pop, an ack or a lease answers: a dropped record is read back from its
cursor row with its partition's next message, as before. Over three hours of a production-like
load (75,000 partitions), the leader held a steady 32,000 records where 2.10.0 climbed to 149,000,
at the same throughput and latency; Jepsen ran 30 tests with the window at 1 s, all valid.

Server: a node can give back the memory its in-memory tables leave scattered, without a restart.
Every row of the replicated tables is its own allocation, placed wherever the allocator had room when
the row was written. After hours of partitions created and cleaned up, cursors moved and dedup rows
expired, the rows still alive keep half-used allocator pages that cannot go back to the system, which
is why a node uses less memory right after a restart: on a test cluster, a follower went from 0.955 to
0.704 GB with the same rows. Now every node runs a background pass every 10 minutes
(QUEEN_STORE_REPACK_EVERY_S, 600; 0 turns it off) that copies each table's rows into fresh
allocations, a stripe at a time, and frees the old copies, the way the load at a restart builds the
tables; QUEEN_STORE_REPACK_ROWS_PER_S (100,000) paces it, at most 1,024 rows under one table lock.
It changes no row and nothing on disk. On a three-node test cluster under three hours of churn, the
follower that repacked held about 15% less memory than the one that did not, with the same rows, and a
restart gave back 0.17-0.19 GB on the second but only 0.05-0.07 GB on the first. With a pass every
minute, push up to 4 million messages a second, transactions up to 1.5 million and 10,000 new
partitions a second ran at the same throughput, CPU and latency.

Server: the dead letters of all queues together have a memory budget. A dead letter keeps a
full copy of its message's body, in memory on every node, loaded again at every start. The caps per
queue (QUEEN_DLQ_MAX_ROWS_PER_QUEUE, QUEEN_DLQ_MAX_BYTES_PER_QUEUE, QUEEN_DLQ_MAX_AGE_S) bound
one queue each, and maintenance applies them after the fact, so a few queues that fail large
messages fast could still fill every node's memory at once; a production cluster's 4,357 dead
letters held 148 MB on every node. QUEEN_DLQ_MAX_BYTES_TOTAL (512 MiB; 0 turns it off) bounds
them all as they are filed: once the dead letters hold it, the leader files a new dead letter
without its body. Its id, transaction id, partition, offset, retry count and error stay, the error
ends with (body not kept: the dead letters held QUEEN_DLQ_MAX_BYTES_TOTAL), the list shows its
data as null, and a replay of it answers 409 with result: "no_body". The leader decides as it
plans the ack, so every node stores the same row. queen_dlq_bytes shows what the dead letters
hold on a node, and queen_dlq_bodies_not_kept_total how many the leader filed without a body.
The per-queue byte cap estimates a queue's bytes from its oldest dead letters; now the estimate is
never more than all dead letters hold, and past the cap the oldest go each by its own size until the
rest fits. A queue whose first failures kept large bodies and whose next ones were filed without
them no longer reads as many times its size and loses dead letters it had room for.

Server: Prometheus counts each queue's partitions, and each consumer group's. Two gauges join
the consumer group lag families: queen_queue_partitions{queue}, the partitions of a queue as the
queue list counts them, and queen_consumer_group_partitions{queue,group}, the partitions where a
group holds a position, its members in GET /api/v1/consumer-groups. Their sums are every
partition of every queue and every position the groups hold, so a graph shows how a cluster grows
without anyone opening the console. The raft leader reads them in the pass that already reads the
group lag at every metrics bucket, so they cost no extra read, and like the lag families they are
left out when QUEEN_METRICS_GROUP_LAG_MAX_CURSORS stops that pass. A filtered group's partitions
are part of its group: they count among its positions, under its queue's name, and in no queue's
partitions.

Server and console: every queue's timers in one read. GET /api/v1/timers answers, for each
queue of the tenant that holds timers, its count and its first perQueue timers by key (100 by
default, at most 1,000), in the rows of GET /api/v1/timers/:queue, without payloads. It is one
linearizable walk of the tenant's timers, at most 200,000: past that it answers "complete": false,
and its counts are those of the timers it walked. Like the other listings, a client token cannot
call it, and the memory guard counts it as a large read. The console's State page read each
queue's timers with a call of its own, 175 calls and about 10 s on a stage cluster of 174 queues;
it now makes one, and on a broker without the route it reads each queue as before.