-
Notifications
You must be signed in to change notification settings - Fork 898
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If we can't update_attributes on a queue row, set state to error
https://bugzilla.redhat.com/show_bug.cgi?id=1429747 In the reported bug, we had a Rails 4.2 era class [1] serialized in the args column of a miq_queue row. This class was removed in rails 5.0.0 [2], so we'd be unable to deserialize the column with: ArgumentError: undefined class/module ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Integer If we're unable to update_attributes because a column can't be deserialized, the message can't be handled by a worker, the worker dies, and the message remains in the miq_queue for another worker to try and also fail on. Instead, if update_attributes fails, we can try to set just the state column to 'error'. In this way, the server will not try to dispatch the same queue multiple times. We clear errored messages at server boot, so we can clean them up then. [1] ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Integer [2] rails/rails@aafee23
- Loading branch information
Showing
3 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
describe MiqQueueWorkerBase::Runner do | ||
context "#get_message_via_drb" do | ||
let(:server) { EvmSpecHelper.local_miq_server } | ||
let(:worker) { FactoryGirl.create(:miq_generic_worker, :miq_server => server, :pid => 123) } | ||
let(:runner) do | ||
allow_any_instance_of(MiqQueueWorkerBase::Runner).to receive(:sync_active_roles) | ||
allow_any_instance_of(MiqQueueWorkerBase::Runner).to receive(:sync_config) | ||
allow_any_instance_of(MiqQueueWorkerBase::Runner).to receive(:set_connection_pool_size) | ||
described_class.new(:guid => worker.guid) | ||
end | ||
|
||
it "sets message to 'error' and raises for unhandled exceptions" do | ||
# simulate what may happen if invalid yaml is deserialized | ||
allow_any_instance_of(MiqQueue).to receive(:args).and_raise(ArgumentError) | ||
q1 = FactoryGirl.create(:miq_queue) | ||
allow(runner) | ||
.to receive(:worker_monitor_drb) | ||
.and_return(double(:get_queue_message => [q1.id, q1.lock_version])) | ||
|
||
expect { runner.get_message_via_drb }.to raise_error(StandardError) | ||
expect(q1.reload.state).to eql(MiqQueue::STATUS_ERROR) | ||
end | ||
end | ||
end |