Description of problem:
On Satellite 6.9.5, I'm getting this failure:
[root@sat6 ~]# foreman-rake facts:clean COMMIT=true --trace
** Invoke facts:clean (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute facts:clean
Starting orphaned facts clean up
ActiveRecord::InvalidForeignKey: PG::ForeignKeyViolation: ERROR: update or delete on table "fact_names" violates foreign key constraint "fact_values_fact_name_id_fk" on table "fact_values"
DETAIL: Key (id)=(5153) is still referenced from table "fact_values".
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-184.108.40.206/lib/active_record/connection_adapters/postgresql_adapter.rb:675:in `block (2 levels) in exec_no_cache'
Version-Release number of selected component (if applicable):
satellite 6.9.5 (fresh upgrade from 6.8.6)
Connecting redmine issue https://projects.theforeman.org/issues/30028 from this bug
Upstream bug assigned to email@example.com
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/30028 has been resolved.
Checked on Satellite 6.11 snap 17, I inserted several entries into the fact_names table: compose/non-compse, without matching fact_values, with null fact values, etc. When running "foreman-rake facts:clean COMMIT=true --trace":
- fact_names without fact_values are removed
- non-compose fact_name with fact_value is left alone without error
- compose fact_name with empty fact_value is removed
- compose fact_name with non-empty fact_value is left alone without error