Project

General

Profile

Bug #17899

DeleteOrphanedSmartClassParameters migration fails

Added by Ohad Levy over 5 years ago. Updated almost 4 years ago.

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

Description

== 20161205142618 DeleteOrphanedSmartClassParameters: migrating ===============
rake aborted!
StandardError: An error has occurred, all later migrations canceled:

(<unknown>): found character that cannot start any token while scanning for the next token at line 1 column 5
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/coders/yaml_column.rb:26:in `load'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/type/serialized.rb:19:in `type_cast_from_database'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/attribute.rb:104:in `type_cast'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/attribute.rb:42:in `original_value'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/attribute.rb:37:in `value'
/home/foreman/gems/gems/activesupport-4.2.7.1/lib/active_support/core_ext/hash/transform_values.rb:11:in `block in transform_values'
/home/foreman/gems/gems/activesupport-4.2.7.1/lib/active_support/core_ext/hash/transform_values.rb:10:in `each'
/home/foreman/gems/gems/activesupport-4.2.7.1/lib/active_support/core_ext/hash/transform_values.rb:10:in `transform_values'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/attribute_set.rb:18:in `to_hash'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/attribute_methods.rb:284:in `attributes'
/home/foreman/gems/gems/audited-4.2.2/lib/audited/auditor.rb:133:in `audited_attributes'
/home/foreman/gems/gems/audited-4.2.2/lib/audited/auditor.rb:202:in `audit_destroy'
/home/foreman/gems/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:432:in `block in make_lambda'
/home/foreman/gems/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:164:in `call'
/home/foreman/gems/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:164:in `block in halting'
/home/foreman/gems/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:504:in `call'
/home/foreman/gems/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:504:in `block in call'
/home/foreman/gems/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:504:in `each'
/home/foreman/gems/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:504:in `call'
/home/foreman/gems/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:92:in `__run_callbacks__'
/home/foreman/gems/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:778:in `_run_destroy_callbacks'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/callbacks.rb:292:in `destroy'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/transactions.rb:281:in `block in destroy'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/transactions.rb:351:in `block in with_transaction_returning_status'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/transactions.rb:220:in `transaction'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/transactions.rb:348:in `with_transaction_returning_status'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/transactions.rb:281:in `destroy'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/relation.rb:403:in `block in destroy_all'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/relation.rb:403:in `each'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/relation.rb:403:in `destroy_all'
/home/foreman/git/foreman/db/migrate/20161205142618_delete_orphaned_smart_class_parameters.rb:3:in `up'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:611:in `exec_migration'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:592:in `block (2 levels) in migrate'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:591:in `block in migrate'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:590:in `migrate'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:768:in `migrate'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:998:in `block in execute_migration_in_transaction'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:1046:in `ddl_transaction'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:997:in `execute_migration_in_transaction'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:959:in `block in migrate'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:955:in `each'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:955:in `migrate'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:823:in `up'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:801:in `migrate'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/home/foreman/gems/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
Psych::SyntaxError: (<unknown>): found character that cannot start any token while scanning for the next token at line 1 column 5
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/coders/yaml_column.rb:26:in `load'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/type/serialized.rb:19:in `type_cast_from_database'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/attribute.rb:104:in `type_cast'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/attribute.rb:42:in `original_value'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/attribute.rb:37:in `value'
/home/foreman/gems/gems/activesupport-4.2.7.1/lib/active_support/core_ext/hash/transform_values.rb:11:in `block in transform_values'
/home/foreman/gems/gems/activesupport-4.2.7.1/lib/active_support/core_ext/hash/transform_values.rb:10:in `each'
/home/foreman/gems/gems/activesupport-4.2.7.1/lib/active_support/core_ext/hash/transform_values.rb:10:in `transform_values'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/attribute_set.rb:18:in `to_hash'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/attribute_methods.rb:284:in `attributes'
/home/foreman/gems/gems/audited-4.2.2/lib/audited/auditor.rb:133:in `audited_attributes'
/home/foreman/gems/gems/audited-4.2.2/lib/audited/auditor.rb:202:in `audit_destroy'
/home/foreman/gems/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:432:in `block in make_lambda'
/home/foreman/gems/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:164:in `call'
/home/foreman/gems/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:164:in `block in halting'
/home/foreman/gems/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:504:in `call'
/home/foreman/gems/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:504:in `block in call'
/home/foreman/gems/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:504:in `each'
/home/foreman/gems/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:504:in `call'
/home/foreman/gems/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:92:in `__run_callbacks__'
/home/foreman/gems/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:778:in `_run_destroy_callbacks'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/callbacks.rb:292:in `destroy'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/transactions.rb:281:in `block in destroy'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/transactions.rb:351:in `block in with_transaction_returning_status'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/transactions.rb:220:in `transaction'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/transactions.rb:348:in `with_transaction_returning_status'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/transactions.rb:281:in `destroy'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/relation.rb:403:in `block in destroy_all'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/relation.rb:403:in `each'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/relation.rb:403:in `destroy_all'
/home/foreman/git/foreman/db/migrate/20161205142618_delete_orphaned_smart_class_parameters.rb:3:in `up'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:611:in `exec_migration'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:592:in `block (2 levels) in migrate'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:591:in `block in migrate'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:590:in `migrate'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:768:in `migrate'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:998:in `block in execute_migration_in_transaction'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:1046:in `ddl_transaction'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:997:in `execute_migration_in_transaction'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:959:in `block in migrate'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:955:in `each'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:955:in `migrate'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:823:in `up'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/migration.rb:801:in `migrate'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/home/foreman/gems/gems/activerecord-4.2.7.1/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/home/foreman/gems/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
Tasks: TOP => db:migrate

Related issues

Related to Foreman - Feature #17810: Delete smart class parameter when a puppet class is deletedClosed2016-12-21

Associated revisions

Revision ffd430c2 (diff)
Added by Ori Rabin over 5 years ago

fixes #17899 - Delete instead of destroy orphaned records

History

#1 Updated by Ohad Levy over 5 years ago

  • Related to Feature #17810: Delete smart class parameter when a puppet class is deleted added

#2 Updated by Dominic Cleal over 5 years ago

  • Category set to DB migrations
  • Legacy Backlogs Release (now unused) set to 209

Stack trace appears to be trying to retrieve attributes of the deleted parameter to populate audits.

#3 Updated by Ohad Levy over 5 years ago

Dominic Cleal wrote:

Stack trace appears to be trying to retrieve attributes of the deleted parameter to populate audits.

the value in the db is:

mysql> SELECT `lookup_keys`.default_value FROM `lookup_keys` WHERE `lookup_keys`.`id` = 978;
+---------------+
| default_value |
+---------------+
| --- %         |
+---------------+
1 row in set (0.00 sec)

I have no idea how it was set in the first place, I assume the yaml parser cant understand this..

One way to avoid this (and many logs in the audit log) would be not to use the real LookupKey/Value objects (maybe something similar to the good_migrations gem).

#4 Updated by Ori Rabin over 5 years ago

  • Status changed from New to Assigned
  • Assignee set to Ori Rabin

#5 Updated by Ori Rabin over 5 years ago

  • Target version set to 1.11.1

#6 Updated by The Foreman Bot over 5 years ago

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

#7 Updated by Ori Rabin over 5 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF