Upgrade step from 5.5 to 5.7 may fail with errors if there are inconsistencies within the OnApp database. For example, if it has been manually manipulated:
Issue 1
Running: onapp:upgrade rake aborted! An error occured upon handling event##<Events::TemplateCreated:0x0000001a479630 @event_id="f987324e-25c0-4a21-ac0b-3d7c58e2979c", @metadata={:timestamp=>Thu, 09 Oct 2014 18:24:06 UTC +00:00}, @data={:template_id=>195, :backup_server_id=>1, :backup_server_zone_id=>8, :label=>"12 ????????", :user_id=>1154, :template_size_kb=>6718784, :for_load_balancer=>false}, @validation_result=#<Dry::Validation::Result output={:template_id=>195, :backup_server_id=>1, :backup_server_zone_id=>8, :label=>"12 ????????", :user_id=>1154, :template_size_kb=>6718784, :for_load_balancer=>false} errors={}>>: Can't find record in `billing_sources_payers` with params {:payer_id=>1154, :payer_type=>1}
Cause: A template record is assigned to non-existing user.
Resolution: The template could be removed or assigned to a valid user.
This select query must provide an empty output:
select user_id from templates where user_id not in (select id from users);
Issue 2
Mysql2::Error: Column 'payer_id' cannot be null: INSERT INTO billing_statistics_monthly ( feature_type, metric_type, value, cost, stat_time, created_at, payer_type, payer_id, target_type, target_id, origin_type, origin_id ) SELECT '98', '1', 1.0, SUM(stats.cost), stats.stat_time, NOW(), 1, stats.payer_id, 0, 0, 0, 0 FROM ( SELECT user_monthly_stats.user_id as payer_id, user_monthly_stats.stat_time, (user_monthly_stats.cost_resources + user_monthly_stats.cost_usage) as cost FROM user_monthly_stats UNION ALL SELECT vm_monthly_stats.user_id as payer_id, vm_monthly_stats.stat_time, (vm_monthly_stats.cost_resources + vm_monthly_stats.cost_usage) as cost FROM vm_monthly_stats ) as stats GROUP BY payer_id, stat_time /onapp/interface/lib/tasks/onapp.rake:187:in `block (2 levels) in <encoded>' Tasks: TOP => billing:legacy:clone_legacy_monthly_stats_into_billing_monthly_statistics
Cause: vm_monthly_stats has records related to non-existing user.
Resolution:
DELETE FROM vm_monthly_stats WHERE user_id IS NULL;
This select must provide an empty output:
select id FROM vm_monthly_stats WHERE user_id IS NULL;
Issue 3
rake aborted!
key not found: ["max_per_target", 12, 1]
/onapp/interface/lib/tasks/onapp.rake:183:in `block (2 levels) in <encoded>'
Tasks: TOP => billing:remove_acceleration_access_controls_from_all_buckets
Resolution:
mysql> delete billing_access_controls_bits from billing_access_controls_bits inner join billing_access_controls_roots on billing_access_controls_roots.id = billing_access_controls_bits.billing_access_controls_root_id and billing_access_controls_roots.type = 'accelerated_servers_resource';
Query OK, 1 row affected (0.03 sec)