{"action":"created","issue":{"url":"https://api.github.com/repos/ManageIQ/manageiq/issues/7332","repository_url":"https://api.github.com/repos/ManageIQ/manageiq","labels_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/7332/labels{/name}","comments_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/7332/comments","events_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/7332/events","html_url":"https://github.com/ManageIQ/manageiq/pull/7332","id":141367747,"number":7332,"title":"Ensure the record is not stale when trying to destroy","user":{"login":"bdunne","id":651659,"avatar_url":"https://avatars.githubusercontent.com/u/651659?v=3","gravatar_id":"","url":"https://api.github.com/users/bdunne","html_url":"https://github.com/bdunne","followers_url":"https://api.github.com/users/bdunne/followers","following_url":"https://api.github.com/users/bdunne/following{/other_user}","gists_url":"https://api.github.com/users/bdunne/gists{/gist_id}","starred_url":"https://api.github.com/users/bdunne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bdunne/subscriptions","organizations_url":"https://api.github.com/users/bdunne/orgs","repos_url":"https://api.github.com/users/bdunne/repos","events_url":"https://api.github.com/users/bdunne/events{/privacy}","received_events_url":"https://api.github.com/users/bdunne/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ManageIQ/manageiq/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/ManageIQ/manageiq/labels/core","name":"core","color":"5319e7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-03-16T18:51:43Z","updated_at":"2016-03-16T21:09:36Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/7332","html_url":"https://github.com/ManageIQ/manageiq/pull/7332","diff_url":"https://github.com/ManageIQ/manageiq/pull/7332.diff","patch_url":"https://github.com/ManageIQ/manageiq/pull/7332.patch"},"body":"I ran into the following at the end of an EMS refresh:\r\n\r\n```\r\n   (0.1ms)  BEGIN\r\n  SQL (0.2ms)  DELETE FROM \"miq_queue\" WHERE \"miq_queue\".\"id\" = $1 AND \"miq_queue\".\"lock_version\" = $2  [[\"id\", 1984], [\"lock_version\", 0]]\r\n   (0.1ms)  ROLLBACK\r\nActiveRecord::StaleObjectError: Attempted to destroy a stale object: MiqQueue.\r\n\tfrom /home/bdunne/.gem/ruby/2.2.4/bundler/gems/rails-4232f7ee427a/activerecord/lib/active_record/locking/optimistic.rb:118:in `destroy_row'\r\n\tfrom /home/bdunne/.gem/ruby/2.2.4/bundler/gems/rails-4232f7ee427a/activerecord/lib/active_record/persistence.rb:184:in `destroy'\r\n\tfrom /home/bdunne/.gem/ruby/2.2.4/bundler/gems/rails-4232f7ee427a/activerecord/lib/active_record/callbacks.rb:283:in `block in destroy'\r\n\tfrom /home/bdunne/.gem/ruby/2.2.4/bundler/gems/rails-4232f7ee427a/activesupport/lib/active_support/callbacks.rb:97:in `__run_callbacks__'\r\n\tfrom /home/bdunne/.gem/ruby/2.2.4/bundler/gems/rails-4232f7ee427a/activesupport/lib/active_support/callbacks.rb:750:in `_run_destroy_callbacks'\r\n\tfrom /home/bdunne/.gem/ruby/2.2.4/bundler/gems/rails-4232f7ee427a/activerecord/lib/active_record/callbacks.rb:283:in `destroy'\r\n\tfrom /home/bdunne/.gem/ruby/2.2.4/bundler/gems/rails-4232f7ee427a/activerecord/lib/active_record/transactions.rb:314:in `block in destroy'\r\n\tfrom /home/bdunne/.gem/ruby/2.2.4/bundler/gems/rails-4232f7ee427a/activerecord/lib/active_record/transactions.rb:395:in `block in with_transaction_returning_status'\r\n\tfrom /home/bdunne/.gem/ruby/2.2.4/bundler/gems/rails-4232f7ee427a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:233:in `block in transaction'\r\n\tfrom /home/bdunne/.gem/ruby/2.2.4/bundler/gems/rails-4232f7ee427a/activerecord/lib/active_record/connection_adapters/abstract/transaction.rb:189:in `within_new_transaction'\r\n\tfrom /home/bdunne/.gem/ruby/2.2.4/bundler/gems/rails-4232f7ee427a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:233:in `transaction'\r\n\tfrom /home/bdunne/.gem/ruby/2.2.4/bundler/gems/rails-4232f7ee427a/activerecord/lib/active_record/transactions.rb:211:in `transaction'\r\n\tfrom /home/bdunne/.gem/ruby/2.2.4/bundler/gems/rails-4232f7ee427a/activerecord/lib/active_record/transactions.rb:392:in `with_transaction_returning_status'\r\n\tfrom /home/bdunne/.gem/ruby/2.2.4/bundler/gems/rails-4232f7ee427a/activerecord/lib/active_record/transactions.rb:314:in `destroy'\r\n\tfrom /home/bdunne/projects/redhat/manageiq/app/models/miq_queue.rb:381:in `delivered'\r\n\tfrom /home/bdunne/projects/redhat/manageiq/lib/vmdb/console_methods.rb:22:in `block in simulate_queue_worker'\r\n\tfrom /home/bdunne/projects/redhat/manageiq/lib/vmdb/console_methods.rb:18:in `loop'\r\n\tfrom /home/bdunne/projects/redhat/manageiq/lib/vmdb/console_methods.rb:18:in `simulate_queue_worker'\r\n\tfrom (irb):1\r\n\tfrom /home/bdunne/.gem/ruby/2.2.4/bundler/gems/rails-4232f7ee427a/railties/lib/rails/commands/console.rb:65:in `start'\r\n\tfrom /home/bdunne/.gem/ruby/2.2.4/bundler/gems/rails-4232f7ee427a/railties/lib/rails/commands/console_helper.rb:9:in `start'\r\n\tfrom /home/bdunne/.gem/ruby/2.2.4/bundler/gems/rails-4232f7ee427a/railties/lib/rails/commands/commands_tasks.rb:78:in `console'\r\n\tfrom /home/bdunne/.gem/ruby/2.2.4/bundler/gems/rails-4232f7ee427a/railties/lib/rails/commands/commands_tasks.rb:49:in `run_command!'\r\n\tfrom /home/bdunne/.gem/ruby/2.2.4/bundler/gems/rails-4232f7ee427a/railties/lib/rails/commands.rb:18:in `<top (required)>'\r\n\tfrom bin/rails:4:in `require'\r\n\tfrom bin/rails:4:in `<main>'\r\n```"},"comment":{"url":"https://api.github.com/repos/ManageIQ/manageiq/issues/comments/197550533","html_url":"https://github.com/ManageIQ/manageiq/pull/7332#issuecomment-197550533","issue_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/7332","id":197550533,"user":{"login":"bdunne","id":651659,"avatar_url":"https://avatars.githubusercontent.com/u/651659?v=3","gravatar_id":"","url":"https://api.github.com/users/bdunne","html_url":"https://github.com/bdunne","followers_url":"https://api.github.com/users/bdunne/followers","following_url":"https://api.github.com/users/bdunne/following{/other_user}","gists_url":"https://api.github.com/users/bdunne/gists{/gist_id}","starred_url":"https://api.github.com/users/bdunne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bdunne/subscriptions","organizations_url":"https://api.github.com/users/bdunne/orgs","repos_url":"https://api.github.com/users/bdunne/repos","events_url":"https://api.github.com/users/bdunne/events{/privacy}","received_events_url":"https://api.github.com/users/bdunne/received_events","type":"User","site_admin":false},"created_at":"2016-03-16T21:09:36Z","updated_at":"2016-03-16T21:09:36Z","body":"@jrafanie Updated based on your comment."}}