Settings error when seeding develop with bootdisk


I am not sure why and I fail to understand this but with recent develop and bootdisk plugin enabled, when I try to seed/migrate I am getting the following error:

rake aborted!
ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "settings_pkey"
DETAIL:  Key (id)=(1073209409) already exists.
/home/lzap/work/foreman/app/models/setting.rb:215:in `block in create!'
/home/lzap/work/foreman/app/models/setting.rb:206:in `create_find_by_name'
/home/lzap/work/foreman/app/models/setting.rb:215:in `create!'
/home/lzap/work/foreman/app/models/setting.rb:289:in `block (2 levels) in load_defaults'
/home/lzap/work/foreman/app/models/setting.rb:287:in `each'
/home/lzap/work/foreman/app/models/setting.rb:287:in `block in load_defaults'
/home/lzap/work/foreman/app/models/setting.rb:286:in `load_defaults'
/home/lzap/work/foreman/config/initializers/foreman.rb:29:in `each'
/home/lzap/work/foreman/config/initializers/foreman.rb:29:in `<top (required)>'
/home/lzap/work/foreman/config/environment.rb:5:in `<top (required)>'
/home/lzap/.rbenv/versions/2.7.1/bin/bundle:23:in `load'
/home/lzap/.rbenv/versions/2.7.1/bin/bundle:23:in `<main>'

The setting in question is bootdisk_syslinux_dir which hasn’t been touched for years. I don’t understand, maybe some recent changes? Anyone?

Is that reproducible when you rerun the seed?

This may be very same problem like with seeding roles. During the installation, the rails environment starts several times in parallel. E.g. rake db:seed and passenger worker loads it. The code that is triggered in initializer then can fail due to the race condition. We just added rescue and reload that record if that happens.

If it shows even on rerun, it is likely a different issue.

I deleted the database and it went away… Thanks.

I hit this again and I think this has something to do with fixtures. I added a new setting and forgot to create a fixture, then I tried to execute a test. This error appears and it would never go away even after I add the missing fixture. The only option is to delete the test database and start over.

Don’t forget to try spring stop, I faved something similar recently when I was switching branches.