Bug #22850

concurrent registration occasionally fails with "host_id has already been taken" error

Added by Justin Sherrill over 4 years ago. Updated almost 4 years ago.

Target version:
Bugzilla link:
Fixed in Releases:
Found in Releases:
Red Hat JIRA:


Cloned from

Description of problem:

If you run a number of concurrent registrations, you will occasionally get this error

2018-03-09 11:01:08 f2291934 [app] [I] Started POST "/rhsm/consumers?owner=Default_Organization&activation_keys=rhel7ak" for at 2018-03-09 11:01:08 -0500
2018-03-09 11:01:08 f2291934 [app] [I] Processing by Katello::Api::Rhsm::CandlepinProxiesController#consumer_activate as JSON
2018-03-09 11:01:08 f2291934 [app] [I] Parameters: {"facts"=>"[FILTERED]", "installedProducts"=>[{"productName"=>"Red Hat Enterprise Linux Server", "arch"=>"x86_64", "version"=>"7.4", "productId"=>"69"}], "type"=>"system", "name"=>"uganda2", "contentTags"=>["rhel-7", "rhel-7-server"], "owner"=>"Default_Organization", "activation_keys"=>"rhel7ak"}
2018-03-09 11:01:11 f2291934 [audit] [I] [uganda2] deleted 0 (5.0ms)
2018-03-09 11:01:11 f2291934 [audit] [I] [uganda2] updated 0 (2.8ms)
2018-03-09 11:01:12 f2291934 [audit] [I] [uganda2] added 111 (847.1ms)
2018-03-09 11:01:12 f2291934 [app] [I] Import facts for 'uganda2' completed. Added: 111, Updated: 0, Deleted 0 facts
2018-03-09 11:01:12 f2291934 [katello/cp_proxy] [E] <Class> ActiveRecord::RecordInvalid
2018-03-09 11:01:12 f2291934 [katello/cp_proxy] [E] host_id: ["has already been taken"]
2018-03-09 11:01:12 f2291934 [app] [I] Completed 422 Unprocessable Entity in 4250ms (Views: 0.4ms | ActiveRecord: 229.6ms)

NOTE: this seems to only occur after 1514508 (6.2.15) is applied.

Version-Release number of selected component (if applicable): 6.2.14 + hotfix for 1514508

How reproducible: maybe 10-20% of time, but sometimes you'll get a number of runs with no error.

Steps to Reproduce:
1. register two hosts at same time

Actual results: error

Expected results: no error

Additional info: the host records all seeem OK in the satellite. clean_backend_objects does not find any missing records, and the host works OK. I am not sure yet why does not return when the 422 is returned, when I connect to the docker host I don't see anything waiting.

Associated revisions

Revision 0012f360 (diff)
Added by Justin Sherrill over 4 years ago

Fixes #22850 - fix registration race condition around sub_status


#1 Updated by The Foreman Bot over 4 years ago

  • Assignee set to Justin Sherrill
  • Status changed from New to Ready For Testing
  • Pull request added

#2 Updated by Andrew Kofink over 4 years ago

  • Legacy Backlogs Release (now unused) set to 284

#3 Updated by Justin Sherrill over 4 years ago

  • Status changed from Ready For Testing to Closed

Also available in: Atom PDF