Provisioning hosts concurrently via API fails with "Name has already been taken" due to invalid Host records created
Environment
- Red Hat Satellite 6.16
Issue
- When attempting to provision a bunch of new hosts concurrently via the Satellite API, the creation process intermittently fails.
- When the physical or virtual nodes boot and attempt to register via
subscription-manager, the registration fails with the following error on the client:HTTP error (422 - Unprocessable Entity): Validation failed: Name has already been taken
Resolution
To resolve the currently locked FQDNs and prevent the issue from occurring on future provisioning runs, follow these steps:
- Clean up the orphaned database records:
To unblock the FQDNs that are currently failing with the 422 error, the corrupted records must be removed directly from the PostgreSQL database. (Note:Ensure you have a working backup or VM snapshot of your Satellite server before performing database modifications).
Execute the following command on the Satellite server CLI to delete the corrupted host entries:
sudo -u postgres psql foreman -c "DELETE FROM hosts WHERE type IS NULL OR type = '';"
- Implement Provisioning Throttling (Workaround):
If you are deploying or creating the hosts via ansible module, it is recommended to implement a throttle parameter on the provisoning task so that it enforece a sequential host creation.
- name: Concurrent registration via Activation Key
theforeman.foreman.host:
# ... your other parameters ...
activation_keys: test-act-key
delegate_to: localhost
throttle: 1
- Optionally, decrease Puma threads to 1 (workaround):
Another workaround is using just 1 Puma thread in each worker. This is not much recommended, as you either loose much of concurrency in foreman/Puma workers, or the increased Puma workers consume extra CPU and memory. Anyway, basic tuning is:
satellite-installer --foreman-foreman-service-puma-threads-max 1 --foreman-foreman-service-puma-threads-min 1 # optionally increase --foreman-foreman-service-puma-workers
- For a final resolution, either upgrade to Satellite 6.17 or higher, or check if Content from redhat.atlassian.net is not included.the underlying bug is fixed in Sat 6.16.
For more KB articles/solutions related to Red Hat Satellite 6.x Provisioning Issues, please refer to the Consolidated Troubleshooting Article for Red Hat Satellite 6.x Provisioning related Issues.
Root Cause
This issue is caused by a concurrency bottleneck and race condition in the Satellite API's host creation controller.
When a high volume of simultaneous API requests (e.g., 20 concurrent requests) hit the Satellite's Puma web server, a concurrency issue among threads within the same process can end up in storing incomplete Host record - type attribute remains NULL. That blocks using the Host record.
Diagnostic Steps
-
subscription-manager registeron the client fails with error:Validation failed: Name has already been taken (HTTP error code 422: Unprocessable Entity) This system is not yet registered. Try 'subscription-manager register --help' for more information. curl: (22) The requested URL returned error: 404 -
/var/log/foreman/production.loghas either of three errors:2026-06-09T11:51:30 [I|app|c166cab8] Started POST "/rhsm/consumers?owner=RedHat&activation_keys=ak_library" for 192.168.xx.xx at 2026-06-09 11:51:30 +0200 .. 2026-06-09T11:51:30 [W|app|c166cab8] Not queueing Host::Managed: ["Name has already been taken"] .. 2026-06-09T11:51:30 [E|kat|c166cab8] <Class> ActiveRecord::RecordInvalid 2026-06-09T11:51:30 [E|kat|c166cab8] name: ["has already been taken"] 2026-06-09T11:51:30 [I|app|c166cab8] Completed 422 Unprocessable Entity in 194ms (Views: 1.3ms | ActiveRecord: 15.4ms | Allocations: 48356) .. 2026-06-09T11:51:31 [I|app|d28c97bb] Started POST "/register" for 192.168.xx.xx at 2026-06-09 11:51:31 +0200 .. 2026-06-09T11:51:31 [I|app|d28c97bb] Authorized user admin(Admin User) 2026-06-09T11:51:31 [I|app|d28c97bb] Host was not found by the subscription UUID: '', this can happen if the host is registered already, but not to this instance (ActiveRecord::RecordNotFound) 2026-06-09T11:51:31 [I|app|d28c97bb] Rendered text template (Duration: 0.0ms | Allocations: 1) 2026-06-09T11:51:31 [I|app|d28c97bb] Completed 404 Not Found in 28ms (Views: 0.3ms | ActiveRecord: 9.9ms | Allocations: 8485) 2026-06-04T09:20:52 [I|app|26ee1346] Started POST "/api/hosts" for 192.168.xx.xx at 2026-06-04 09:20:52 +0200 .. 2026-06-04T09:20:52 [W|app|26ee1346] Not queueing Host::Managed: ["Name has already been taken"] .. 2026-06-04T09:20:52 [E|app|26ee1346] Unprocessable entity Host::Managed (id: new): 26ee1346 | Name has already been taken 26ee1346 | 2026-06-04T09:20:52 [I|app|26ee1346] Rendered api/v2/errors/unprocessable_entity.json.rabl within api/v2/layouts/error_layout (Duration: 1.9ms | Allocations: 3244) 2026-06-04T09:20:52 [I|app|26ee1346] Rendered layout api/v2/layouts/error_layout.json.erb (Duration: 2.1ms | Allocations: 3336) 2026-06-04T09:20:52 [I|app|26ee1346] Completed 422 Unprocessable Entity in 41ms (Views: 2.4ms | ActiveRecord: 5.5ms | Allocations: 45474) -
Run the following PostgreSQL query on the Satellite server to confirm the presence of orphaned records lacking a host type. You will see the example Output
sudo -u postgres psql foreman -c "SELECT id, name, type, organization_id, location_id FROM hosts WHERE type IS NULL OR type = '';" : id | name | type | organization_id | location_id -------+----------------------------------+------+-----------------+------------- 21935 | hrz-ansible-cobra.0001.acme.local | | 6 | 2
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.