From 551f2640737911ba195a4b2e0743dfe16264199b Mon Sep 17 00:00:00 2001 From: Cody Cutrer Date: Wed, 25 Oct 2023 12:57:44 -0600 Subject: [PATCH] fix failsafe on pipelined refs CNVS-60234 `...` was stuffing the failsafe kwarg into a hash as the first non-kwarg Change-Id: Ia0b468416be130e1134b5e814f69faac9581f9f2 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/331323 Reviewed-by: Ryan Norton Product-Review: Ryan Norton Tested-by: Service Cloud Jenkins QA-Review: Cody Cutrer --- gems/canvas_cache/lib/canvas_cache/redis.rb | 4 ++-- gems/canvas_cache/spec/canvas_cache/redis_spec.rb | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gems/canvas_cache/lib/canvas_cache/redis.rb b/gems/canvas_cache/lib/canvas_cache/redis.rb index bf9a21518e0..038f6e07fe7 100644 --- a/gems/canvas_cache/lib/canvas_cache/redis.rb +++ b/gems/canvas_cache/lib/canvas_cache/redis.rb @@ -44,9 +44,9 @@ module CanvasCache end module IgnorePipelinedKey - def pipelined(_key = nil, ...) + def pipelined(_key = nil, **kwargs, &) # ignore key; only useful for distributed - super(...) + super(**kwargs, &) end end diff --git a/gems/canvas_cache/spec/canvas_cache/redis_spec.rb b/gems/canvas_cache/spec/canvas_cache/redis_spec.rb index 65706b203d5..4c9d99dc637 100644 --- a/gems/canvas_cache/spec/canvas_cache/redis_spec.rb +++ b/gems/canvas_cache/spec/canvas_cache/redis_spec.rb @@ -295,6 +295,15 @@ describe CanvasCache::Redis do allow(Process).to receive(:clock_gettime).and_return(now + 4) expect { redis_client.get("mykey") }.to raise_error(Redis::CannotConnectError) end + + it "support failsafe with pipeline" do + expect(redis_client.pipelined(failsafe: 2) { raise Redis::CannotConnectError }).to eq(2) + end + + it "support failsafe with pipeline on a distributed client" do + client = Redis::Distributed.new([redis_client.id]) + expect(client.pipelined("key", failsafe: 2) { raise Redis::CannotConnectError }).to eq(2) + end end end end