From 9ca5d7d5a36b4bb8eb44d5716cec33b7c740679f Mon Sep 17 00:00:00 2001 From: Dmitry Rybakov Date: Thu, 31 Oct 2024 12:54:14 +0100 Subject: [PATCH] RUBY-3571 Add TransientTransactionError label to PoolClearedError --- lib/mongo/error/pool_cleared_error.rb | 1 + spec/mongo/error/pool_cleared_error_spec.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 spec/mongo/error/pool_cleared_error_spec.rb diff --git a/lib/mongo/error/pool_cleared_error.rb b/lib/mongo/error/pool_cleared_error.rb index 6f8b493e1a..d52b1ae198 100644 --- a/lib/mongo/error/pool_cleared_error.rb +++ b/lib/mongo/error/pool_cleared_error.rb @@ -31,6 +31,7 @@ class PoolClearedError < PoolError # # @api private def initialize(address, pool) + add_label('TransientTransactionError') super(address, pool, "Connection to #{address} interrupted due to server monitor timeout " + "(for pool 0x#{pool.object_id})") diff --git a/spec/mongo/error/pool_cleared_error_spec.rb b/spec/mongo/error/pool_cleared_error_spec.rb new file mode 100644 index 0000000000..f45b016c5e --- /dev/null +++ b/spec/mongo/error/pool_cleared_error_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'lite_spec_helper' + +describe Mongo::Error::PoolClearedError do + describe '#initialize' do + let(:error) do + described_class.new(double('address'), double('pool')) + end + + it 'appends TransientTransactionError' do + expect(error.labels).to include('TransientTransactionError') + end + end +end