From df310f6ae377bf1dbac05da7c48f5e171f092165 Mon Sep 17 00:00:00 2001 From: Matteo Cafasso Date: Tue, 10 Dec 2024 23:37:59 +0200 Subject: [PATCH 1/4] backing_queue: simplify `is_duplicate` callback signature `is_duplicate` callback signature was changed in order to support both the mirroring queues as well as the de-duplication ones. As the mirroring queues are now deprecated and removed, we can fall back to a simpler boolean as return value. Signed-off-by: Matteo Cafasso (cherry picked from commit c927446e17c825208db7c734be160b91b6090c67) (cherry picked from commit 6a6e76010709d63883791905dfe76675fe6c8e8f) --- deps/rabbit/src/rabbit_backing_queue.erl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/deps/rabbit/src/rabbit_backing_queue.erl b/deps/rabbit/src/rabbit_backing_queue.erl index ffa0a791f1b5..3169cbf87bfd 100644 --- a/deps/rabbit/src/rabbit_backing_queue.erl +++ b/deps/rabbit/src/rabbit_backing_queue.erl @@ -220,9 +220,8 @@ %% Called prior to a publish or publish_delivered call. Allows the BQ %% to signal that it's already seen this message, (e.g. it was published -%% or discarded previously) specifying whether to drop the message or reject it. --callback is_duplicate(mc:state(), state()) - -> {{true, drop} | {true, reject} | boolean(), state()}. +%% or discarded previously). +-callback is_duplicate(mc:state(), state()) -> {boolean(), state()}. -callback set_queue_mode(queue_mode(), state()) -> state(). From 6837695cc175e1037cc66f0dc3afd1aa044c7654 Mon Sep 17 00:00:00 2001 From: Matteo Cafasso Date: Tue, 10 Dec 2024 23:57:44 +0200 Subject: [PATCH 2/4] amqqueue_process: adopt new `is_duplicate` backing queue callback As the de-duplication plugin is the only adopter of the `is_duplicate` callback, we now use a simpler signature. When a message is deemed duplicated, we discard it and re-route it to dead letter exchange. Signed-off-by: Matteo Cafasso (cherry picked from commit f93baa35cbdcb1ad56dd52f414abf3376371d12a) (cherry picked from commit 8d7535e0b12c6512e582ab201feaa9218c1f776d) --- deps/rabbit/src/rabbit_amqqueue_process.erl | 23 ++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/deps/rabbit/src/rabbit_amqqueue_process.erl b/deps/rabbit/src/rabbit_amqqueue_process.erl index 63f886bd3763..097cf6dde67b 100644 --- a/deps/rabbit/src/rabbit_amqqueue_process.erl +++ b/deps/rabbit/src/rabbit_amqqueue_process.erl @@ -725,13 +725,26 @@ maybe_deliver_or_enqueue(Delivery = #delivery{message = Message}, {IsDuplicate, BQS1} = BQ:is_duplicate(Message, BQS), State1 = State#q{backing_queue_state = BQS1}, case IsDuplicate of - true -> State1; - {true, drop} -> State1; - %% Drop publish and nack to publisher - {true, reject} -> + true -> + %% Publish to DLX + _ = with_dlx( + DLX, + fun (X) -> + rabbit_global_counters:messages_dead_lettered(maxlen, + rabbit_classic_queue, + at_most_once, 1), + QName = qname(State1), + rabbit_dead_letter:publish(Message, maxlen, X, RK, QName) + end, + fun () -> + rabbit_global_counters:messages_dead_lettered(maxlen, + rabbit_classic_queue, + disabled, 1) + end), + %% Drop publish and nack to publisher send_reject_publish(Delivery, State1); - %% Enqueue and maybe drop head later false -> + %% Enqueue and maybe drop head later deliver_or_enqueue(Delivery, Delivered, State1) end end. From 2a3c35ad90b4e0198b73aaed17a8f9e33bfe0a76 Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Thu, 12 Dec 2024 16:30:39 -0500 Subject: [PATCH 3/4] Test workflows: export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT (cherry picked from commit bdce755c4ef42434f97459a23855e11d7244d0ef) --- .github/workflows/test-make-tests.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test-make-tests.yaml b/.github/workflows/test-make-tests.yaml index 5fa4c6e43d48..8cde4de768d0 100644 --- a/.github/workflows/test-make-tests.yaml +++ b/.github/workflows/test-make-tests.yaml @@ -17,6 +17,8 @@ on: jobs: test-rabbit: name: Test rabbit + env: + DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: "1" strategy: fail-fast: false matrix: From b438356f3dc17112254a477b861bd50548686330 Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Thu, 12 Dec 2024 16:31:32 -0500 Subject: [PATCH 4/4] Try running plugin tests on Ubuntu 22.04 (cherry picked from commit 78602ec8c3c4fca2ec34f29d87f95e8819e682b7) --- .github/workflows/test-make-tests.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-make-tests.yaml b/.github/workflows/test-make-tests.yaml index 8cde4de768d0..4fca4ab383ab 100644 --- a/.github/workflows/test-make-tests.yaml +++ b/.github/workflows/test-make-tests.yaml @@ -68,6 +68,7 @@ jobs: test-plugin: name: Test plugins + runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: