instructure / canvas-lms

The open LMS by Instructure, Inc.
https://github.com/instructure/canvas-lms/wiki
GNU Affero General Public License v3.0
5.71k stars 2.52k forks source link

RAILS_ENV=production bundle exec rake db:initial_setup - rake aborted, StandardError #2116

Open rbeason opened 2 years ago

rbeason commented 2 years ago

Summary: initial_setup rake aborted, StandardError

Steps to reproduce:

1.run the command RAILS_ENV=production bundle exec rake db:initial_setup

Command Output:

undefined method id' for nil:NilClass /var/canvas/lib/data_fixup/change_immersive_reader_allowed_on_to_on.rb:24:inrun' /var/canvas/db/migrate/20210823222355_change_immersive_reader_allowed_on_to_on.rb:24:in up' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:830:inup' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:870:in public_send' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:870:inexec_migration' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:851:in block (2 levels) in migrate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:850:inblock in migrate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:462:in with_connection' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:849:inmigrate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-inst-jobs-4.0.12/lib/switchman_inst_jobs/active_record/migration.rb:16:in migrate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:663:inmigrate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:1037:in migrate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:1329:inblock in execute_migration_in_transaction' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:1380:in block in ddl_transaction' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/abstract/database_statements.rb:320:inblock in transaction' /var/canvas/config/initializers/active_record.rb:2184:in block in within_new_transaction' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:inblock (2 levels) in synchronize' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in handle_interrupt' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:inblock in synchronize' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in handle_interrupt' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:insynchronize' /var/canvas/config/initializers/active_record.rb:2182:in within_new_transaction' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/abstract/database_statements.rb:320:intransaction' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/transactions.rb:209:in transaction' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/switchman/active_record/base.rb:35:inblock in transaction' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/switchman/database_server.rb:153:in unguard' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/switchman/active_record/base.rb:35:intransaction' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:1380:in ddl_transaction' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:1328:inexecute_migration_in_transaction' /var/canvas/config/initializers/active_record.rb:1648:in execute_migration_in_transaction' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:1302:ineach' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:1302:in migrate_without_lock' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:1251:inblock in migrate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:1401:in block in with_advisory_lock' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/switchman/active_record/migration.rb:40:inblock in with_advisory_lock_connection' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:462:in with_connection' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/switchman/active_record/migration.rb:40:inwith_advisory_lock_connection' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:1397:in with_advisory_lock' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:1251:inmigrate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:1086:in up' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:1061:inmigrate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/tasks/database_tasks.rb:237:in migrate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/tasks/switchman.rake:8:inblock in <top (required)>' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/tasks/switchman.rake:84:in block (6 levels) in shardify_task' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/tasks/switchman.rake:84:ineach' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/tasks/switchman.rake:84:in block (5 levels) in shardify_task' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/switchman/database_server.rb:153:inunguard' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/tasks/switchman.rake:83:in block (4 levels) in shardify_task' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/switchman/shard.rb:206:inblock (2 levels) in with_each_shard' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/switchman/shard.rb:62:in activate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/switchman/shard.rb:474:inactivate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/switchman/shard.rb:205:in block in with_each_shard' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/relation/delegation.rb:88:ineach' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/relation/delegation.rb:88:in each' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/switchman/shard.rb:201:inwith_each_shard' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/tasks/switchman.rake:79:in block (3 levels) in shardify_task' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/switchman/database_server.rb:153:inunguard' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/tasks/switchman.rake:77:in block (2 levels) in shardify_task' /var/canvas/vendor/bundle/ruby/2.7.0/gems/guardrail-3.0.2/lib/guard_rail.rb:11:inblock in activate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/connection_handling.rb:388:in with_role_and_shard' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/connection_handling.rb:175:inconnected_to' /var/canvas/vendor/bundle/ruby/2.7.0/gems/guardrail-3.0.2/lib/guard_rail.rb:11:in activate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/switchman/guard_rail.rb:13:inactivate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-inst-jobs-4.0.12/lib/switchman_inst_jobs/guard_rail.rb:8:in activate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/tasks/switchman.rake:76:inblock in shardify_task' /var/canvas/vendor/bundle/ruby/2.7.0/gems/sentry-ruby-core-5.1.0/lib/sentry/rake.rb:26:in execute' /var/canvas/lib/tasks/db_load_data.rake:224:inblock (2 levels) in <top (required)>' /var/canvas/vendor/bundle/ruby/2.7.0/gems/sentry-ruby-core-5.1.0/lib/sentry/rake.rb:26:in execute' /var/canvas/vendor/bundle/ruby/2.7.0/gems/rake-13.0.3/exe/rake:27:in<top (required)>'

Caused by: NoMethodError: undefined method id' for nil:NilClass /var/canvas/lib/data_fixup/change_immersive_reader_allowed_on_to_on.rb:24:inrun' /var/canvas/db/migrate/20210823222355_change_immersive_reader_allowed_on_to_on.rb:24:in up' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:830:inup' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:870:in public_send' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:870:inexec_migration' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:851:in block (2 levels) in migrate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:850:inblock in migrate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:462:in with_connection' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:849:inmigrate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-inst-jobs-4.0.12/lib/switchman_inst_jobs/active_record/migration.rb:16:in migrate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:663:inmigrate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:1037:in migrate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:1329:inblock in execute_migration_in_transaction' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:1380:in block in ddl_transaction' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/abstract/database_statements.rb:320:inblock in transaction' /var/canvas/config/initializers/active_record.rb:2184:in block in within_new_transaction' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:inblock (2 levels) in synchronize' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in handle_interrupt' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:inblock in synchronize' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in handle_interrupt' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:insynchronize' /var/canvas/config/initializers/active_record.rb:2182:in within_new_transaction' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/abstract/database_statements.rb:320:intransaction' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/transactions.rb:209:in transaction' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/switchman/active_record/base.rb:35:inblock in transaction' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/switchman/database_server.rb:153:in unguard' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/switchman/active_record/base.rb:35:intransaction' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:1380:in ddl_transaction' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:1328:inexecute_migration_in_transaction' /var/canvas/config/initializers/active_record.rb:1648:in execute_migration_in_transaction' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:1302:ineach' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:1302:in migrate_without_lock' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:1251:inblock in migrate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:1401:in block in with_advisory_lock' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/switchman/active_record/migration.rb:40:inblock in with_advisory_lock_connection' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:462:in with_connection' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/switchman/active_record/migration.rb:40:inwith_advisory_lock_connection' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:1397:in with_advisory_lock' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:1251:inmigrate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:1086:in up' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/migration.rb:1061:inmigrate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/tasks/database_tasks.rb:237:in migrate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/tasks/switchman.rake:8:inblock in <top (required)>' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/tasks/switchman.rake:84:in block (6 levels) in shardify_task' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/tasks/switchman.rake:84:ineach' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/tasks/switchman.rake:84:in block (5 levels) in shardify_task' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/switchman/database_server.rb:153:inunguard' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/tasks/switchman.rake:83:in block (4 levels) in shardify_task' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/switchman/shard.rb:206:inblock (2 levels) in with_each_shard' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/switchman/shard.rb:62:in activate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/switchman/shard.rb:474:inactivate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/switchman/shard.rb:205:in block in with_each_shard' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/relation/delegation.rb:88:ineach' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/relation/delegation.rb:88:in each' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/switchman/shard.rb:201:inwith_each_shard' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/tasks/switchman.rake:79:in block (3 levels) in shardify_task' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/switchman/database_server.rb:153:inunguard' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/tasks/switchman.rake:77:in block (2 levels) in shardify_task' /var/canvas/vendor/bundle/ruby/2.7.0/gems/guardrail-3.0.2/lib/guard_rail.rb:11:inblock in activate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/connection_handling.rb:388:in with_role_and_shard' /var/canvas/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4.6/lib/active_record/connection_handling.rb:175:inconnected_to' /var/canvas/vendor/bundle/ruby/2.7.0/gems/guardrail-3.0.2/lib/guard_rail.rb:11:in activate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/switchman/guard_rail.rb:13:inactivate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-inst-jobs-4.0.12/lib/switchman_inst_jobs/guard_rail.rb:8:in activate' /var/canvas/vendor/bundle/ruby/2.7.0/gems/switchman-3.1.3/lib/tasks/switchman.rake:76:inblock in shardify_task' /var/canvas/vendor/bundle/ruby/2.7.0/gems/sentry-ruby-core-5.1.0/lib/sentry/rake.rb:26:in execute' /var/canvas/lib/tasks/db_load_data.rake:224:inblock (2 levels) in <top (required)>' /var/canvas/vendor/bundle/ruby/2.7.0/gems/sentry-ruby-core-5.1.0/lib/sentry/rake.rb:26:in execute' /var/canvas/vendor/bundle/ruby/2.7.0/gems/rake-13.0.3/exe/rake:27:in<top (required)>' Tasks: TOP => db:migrate (See full trace by running task with --trace)

huangdengpan commented 1 year ago

https://github.com/instructure/canvas-lms/wiki/Production-Start

Once your database is configured, and assets are installed, we need to actually fill the database with tables and initial data. You can do this by running our rake migration and initialization tasks from your application's root:

sysadmin@appserver:/var/canvas$ RAILS_ENV=production bundle exec rake db:initial_setup Note (2022-Aug-04): A few issues exist in the initial setup script that can be worked around using the following commands:

sysadmin@appserver:/var/canvas$ mv db/migrate/20210823222355_change_immersive_reader_allowed_on_to_on.rb . sysadmin@appserver:/var/canvas$ mv db/migrate/20210812210129_add_singleton_column.rb db/migrate/20111111214311_add_singleton_column.rb sysadmin@appserver:/var/canvas$ RAILS_ENV=production bundle exec rake db:initial_setup sysadmin@appserver:/var/canvas$ mv 20210823222355_change_immersive_reader_allowed_on_to_on.rb db/migrate/. sysadmin@appserver:/var/canvas$ RAILS_ENV=production bundle exec rake db:migrate