Project

General

Profile

Bug #29272

template seeding fails during app initialization

Added by Tomer Brisker 8 months ago. Updated 7 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
DB migrations
Target version:
Difficulty:
Triaged:
No
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

inputs_unchanged_when_locked validator doesn't run in rake, but since we are seeding the db now in app initialization and not rake this is triggered causing the seeding to fail.


Related issues

Related to Foreman - Bug #29008: rake db:seed can fail on updating locked templateClosed
Related to Foreman - Feature #28519: Allow storing if db:seed is required within the DB.Closed

Associated revisions

Revision ed22f843 (diff)
Added by Shira Maximov 7 months ago

Fixes #29272 - add template locked error only in not seeding

otherwise, running the server will fail while seeding (In case a template Input was changed)
stepes to reprodcue :
1. run : Template.find_by_name("Registered users").template_inputs.first.update_column(:value_type, "plain")
2. run rails server

History

#1 Updated by Tomer Brisker 8 months ago

  • Is duplicate of Bug #29008: rake db:seed can fail on updating locked template added

#2 Updated by Tomer Brisker 8 months ago

  • Is duplicate of deleted (Bug #29008: rake db:seed can fail on updating locked template)

#3 Updated by Tomer Brisker 8 months ago

  • Related to Bug #29008: rake db:seed can fail on updating locked template added

#4 Updated by Tomer Brisker 8 months ago

  • Related to Feature #28519: Allow storing if db:seed is required within the DB. added

#5 Updated by Shira Maximov 7 months ago

  • Assignee set to Shira Maximov

#6 Updated by Tomer Brisker 7 months ago

Full stacktrace:

2020-03-12T11:04:01 [D|app|] updating existing template
2020-03-12T11:04:01 [D|app|] setting attributes for Registered users with id: 246
2020-03-12T11:04:01 [D|sql|]   TemplateInput Load (0.3ms)  SELECT "template_inputs".* FROM "template_inputs" WHERE "template_inputs"."template_id" = $1  [["template_id", 246]]
2020-03-12T11:04:01 [D|sql|]   ↳ app/models/template.rb:191
2020-03-12T11:04:01 [D|sql|]   TemplateInput Exists (0.4ms)  SELECT  1 AS one FROM "template_inputs" WHERE "template_inputs"."name" = $1 AND "template_inputs"."id" != $2 AND "template_inputs"."template_id" = $3 LIMIT $4  [["name", "Users filter"], ["id", 51], ["template_id", 246], ["LIMIT", 1]]
2020-03-12T11:04:01 [D|sql|]   ↳ lib/seed_helper.rb:129
2020-03-12T11:04:01 [D|sql|]   ReportTemplate Exists (0.3ms)  SELECT  1 AS one FROM "templates" WHERE "templates"."type" IN ('ReportTemplate') AND "templates"."name" = $1 AND "templates"."id" != $2 LIMIT $3  [["name", "Registered users"], ["id", 246], ["LIMIT", 1]]
2020-03-12T11:04:01 [D|sql|]   ↳ lib/seed_helper.rb:129
2020-03-12T11:04:01 [D|sql|]    (0.1ms)  BEGIN
2020-03-12T11:04:01 [D|sql|]   ↳ lib/seed_helper.rb:132
2020-03-12T11:04:01 [D|sql|]   TemplateInput Exists (0.3ms)  SELECT  1 AS one FROM "template_inputs" WHERE "template_inputs"."name" = $1 AND "template_inputs"."id" != $2 AND "template_inputs"."template_id" = $3 LIMIT $4  [["name", "Users filter"], ["id", 51], ["template_id", 246], ["LIMIT", 1]]
2020-03-12T11:04:01 [D|sql|]   ↳ lib/seed_helper.rb:132
2020-03-12T11:04:01 [D|sql|]   ReportTemplate Exists (0.3ms)  SELECT  1 AS one FROM "templates" WHERE "templates"."type" IN ('ReportTemplate') AND "templates"."name" = $1 AND "templates"."id" != $2 LIMIT $3  [["name", "Registered users"], ["id", 246], ["LIMIT", 1]]
2020-03-12T11:04:01 [D|sql|]   ↳ lib/seed_helper.rb:132
2020-03-12T11:04:01 [D|sql|]    (0.3ms)  ROLLBACK
2020-03-12T11:04:01 [D|sql|]   ↳ lib/seed_helper.rb:132
2020-03-12T11:04:01 [E|app|] Error while attempting to seed database, please run `foreman-rake db:seed` manually!
2020-03-12T11:04:01 [E|app|] Traceback (most recent call last):
 |     108: from bin/rails:3:in `<main>'
 |     107: from bin/rails:3:in `load'
 |     106: from /home/tbrisker/foreman/bin/spring:13:in `<top (required)>'
 |     105: from /home/tbrisker/foreman/bin/spring:13:in `require'
 |     104: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `<top (required)>'
 |     103: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `load'
 |     102: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/spring-2.1.0/bin/spring:49:in `<top (required)>'
 |     101: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/spring-2.1.0/lib/spring/client.rb:30:in `run'
 |     100: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/spring-2.1.0/lib/spring/client/command.rb:7:in `call'
 |      99: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `call'
 |      98: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `load'
 |      97: from /home/tbrisker/foreman/bin/rails:9:in `<top (required)>'
 |      96: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `require'
 |      95: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:253:in `load_dependency'
 |      94: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `block in require'
 |      93: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
 |      92: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
 |      91: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
 |      90: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
 |      89: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
 |      88: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/railties-5.2.1/lib/rails/commands.rb:18:in `<top (required)>'
 |      87: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/railties-5.2.1/lib/rails/command.rb:46:in `invoke'
 |      86: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/railties-5.2.1/lib/rails/command/base.rb:65:in `perform'
 |      85: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
 |      84: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
 |      83: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
 |      82: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/railties-5.2.1/lib/rails/commands/server/server_command.rb:142:in `perform'
 |      81: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/railties-5.2.1/lib/rails/commands/server/server_command.rb:142:in `tap'
 |      80: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/railties-5.2.1/lib/rails/commands/server/server_command.rb:147:in `block in perform'
 |      79: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/railties-5.2.1/lib/rails/commands/server/server_command.rb:51:in `start'
 |      78: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/railties-5.2.1/lib/rails/commands/server/server_command.rb:89:in `log_to_stdout'
 |      77: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/rack-2.0.9/lib/rack/server.rb:354:in `wrapped_app'
 |      76: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/railties-5.2.1/lib/rails/commands/server/server_command.rb:27:in `app'
 |      75: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/rack-2.0.9/lib/rack/server.rb:219:in `app'
 |      74: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/rack-2.0.9/lib/rack/server.rb:319:in `build_app_and_options_from_config'
 |      73: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/rack-2.0.9/lib/rack/builder.rb:40:in `parse_file'
 |      72: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/rack-2.0.9/lib/rack/builder.rb:49:in `new_from_string'
 |      71: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/rack-2.0.9/lib/rack/builder.rb:49:in `eval'
 |      70: from config.ru:in `<main>'
 |      69: from config.ru:in `new'
 |      68: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/rack-2.0.9/lib/rack/builder.rb:55:in `initialize'
 |      67: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/rack-2.0.9/lib/rack/builder.rb:55:in `instance_eval'
 |      66: from config.ru:5:in `block in <main>'
 |      65: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `require'
 |      64: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:253:in `load_dependency'
 |      63: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `block in require'
 |      62: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
 |      61: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
 |      60: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
 |      59: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
 |      58: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
 |      57: from /home/tbrisker/foreman/config/environment.rb:5:in `<top (required)>'
 |      56: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/railties-5.2.1/lib/rails/railtie.rb:190:in `method_missing'
 |      55: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/railties-5.2.1/lib/rails/railtie.rb:190:in `public_send'
 |      54: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/railties-5.2.1/lib/rails/application.rb:361:in `initialize!'
 |      53: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/railties-5.2.1/lib/rails/initializable.rb:60:in `run_initializers'
 |      52: from /home/tbrisker/.rvm/rubies/ruby-2.5.7/lib/ruby/2.5.0/tsort.rb:205:in `tsort_each'
 |      51: from /home/tbrisker/.rvm/rubies/ruby-2.5.7/lib/ruby/2.5.0/tsort.rb:226:in `tsort_each'
 |      50: from /home/tbrisker/.rvm/rubies/ruby-2.5.7/lib/ruby/2.5.0/tsort.rb:347:in `each_strongly_connected_component'
 |      49: from /home/tbrisker/.rvm/rubies/ruby-2.5.7/lib/ruby/2.5.0/tsort.rb:347:in `call'
 |      48: from /home/tbrisker/.rvm/rubies/ruby-2.5.7/lib/ruby/2.5.0/tsort.rb:347:in `each'
 |      47: from /home/tbrisker/.rvm/rubies/ruby-2.5.7/lib/ruby/2.5.0/tsort.rb:349:in `block in each_strongly_connected_component'
 |      46: from /home/tbrisker/.rvm/rubies/ruby-2.5.7/lib/ruby/2.5.0/tsort.rb:431:in `each_strongly_connected_component_from'
 |      45: from /home/tbrisker/.rvm/rubies/ruby-2.5.7/lib/ruby/2.5.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
 |      44: from /home/tbrisker/.rvm/rubies/ruby-2.5.7/lib/ruby/2.5.0/tsort.rb:228:in `block in tsort_each'
 |      43: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/railties-5.2.1/lib/rails/initializable.rb:61:in `block in run_initializers'
 |      42: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/railties-5.2.1/lib/rails/initializable.rb:32:in `run'
 |      41: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/railties-5.2.1/lib/rails/initializable.rb:32:in `instance_exec'
 |      40: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/railties-5.2.1/lib/rails/application/finisher.rb:75:in `block in <module:Finisher>'
 |      39: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
 |      38: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:51:in `each'
 |      37: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
 |      36: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook'
 |      35: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control'
 |      34: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
 |      33: from /home/tbrisker/foreman/config/initializers/seeds.rb:13:in `block (2 levels) in <top (required)>'
 |      32: from /home/tbrisker/foreman/app/services/foreman_seeder.rb:32:in `execute'
 |      31: from /home/tbrisker/foreman/app/services/foreman_seeder.rb:32:in `each'
 |      30: from /home/tbrisker/foreman/app/services/foreman_seeder.rb:38:in `block in execute'
 |      29: from /home/tbrisker/foreman/app/models/concerns/foreman/thread_session.rb:114:in `as_anonymous_admin'
 |      28: from /home/tbrisker/foreman/app/models/concerns/foreman/thread_session.rb:108:in `as'
 |      27: from /home/tbrisker/foreman/app/services/foreman_seeder.rb:39:in `block (2 levels) in execute'
 |      26: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:281:in `load'
 |      25: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:253:in `load_dependency'
 |      24: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:281:in `block in load'
 |      23: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load'
 |      22: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load'
 |      21: from /home/tbrisker/foreman/db/seeds.d/090-report_templates.rb:2:in `<top (required)>'
 |      20: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/audited-4.9.0/lib/audited/auditor.rb:376:in `without_auditing'
 |      19: from /home/tbrisker/foreman/db/seeds.d/090-report_templates.rb:3:in `block in <top (required)>'
 |      18: from /home/tbrisker/foreman/lib/seed_helper.rb:137:in `import_templates'
 |      17: from /home/tbrisker/foreman/lib/seed_helper.rb:137:in `each'
 |      16: from /home/tbrisker/foreman/lib/seed_helper.rb:138:in `block in import_templates'
 |      15: from /home/tbrisker/foreman/lib/seed_helper.rb:132:in `import_raw_template'
 |      14: from /home/tbrisker/foreman/app/models/template.rb:69:in `ignore_locking'
 |      13: from /home/tbrisker/foreman/lib/seed_helper.rb:132:in `block in import_raw_template'
 |      12: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/activerecord-5.2.1/lib/active_record/suppressor.rb:48:in `save!'
 |      11: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/activerecord-5.2.1/lib/active_record/transactions.rb:315:in `save!'
 |      10: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/activerecord-5.2.1/lib/active_record/transactions.rb:385:in `with_transaction_returning_status'
 |       9: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/activerecord-5.2.1/lib/active_record/transactions.rb:212:in `transaction'
 |       8: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/database_statements.rb:254:in `transaction'
 |       7: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/transaction.rb:236:in `within_new_transaction'
 |       6: from /home/tbrisker/.rvm/rubies/ruby-2.5.7/lib/ruby/2.5.0/monitor.rb:235:in `mon_synchronize'
 |       5: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/transaction.rb:239:in `block in within_new_transaction'
 |       4: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/database_statements.rb:254:in `block in transaction'
 |       3: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/activerecord-5.2.1/lib/active_record/transactions.rb:387:in `block in with_transaction_returning_status'
 |       2: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/activerecord-5.2.1/lib/active_record/transactions.rb:315:in `block in save!'
 |       1: from /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/activerecord-5.2.1/lib/active_record/validations.rb:52:in `save!'
 | /home/tbrisker/.rvm/gems/ruby-2.5.7@foreman/gems/activerecord-5.2.1/lib/active_record/validations.rb:80:in `raise_validation_error': Validation failed: This template is locked. Please clone it to a new template to customize. (ActiveRecord::RecordInvalid)

#7 Updated by The Foreman Bot 7 months ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/7526 added

#8 Updated by The Foreman Bot 7 months ago

  • Fixed in Releases 2.1.0 added

#9 Updated by Tomer Brisker 7 months ago

  • Fixed in Releases 2.0.0 added
  • Fixed in Releases deleted (2.1.0)

#10 Updated by Shira Maximov 7 months ago

  • Status changed from Ready For Testing to Closed

Also available in: Atom PDF