Project

General

Profile

Bug #2083

DB migration fails with Postgres in 038125b323

Added by Andreas Ntaflos over 9 years ago. Updated over 9 years ago.

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

Description

Running from the develop branch (currently on 038125b323 after not having updated for two months) I get the following errors when running RAILS_ENV=production bundle exec rake db:migrate:

==  CreateNics: migrating =====================================================
-- create_table(:nics)
NOTICE:  CREATE TABLE will create implicit sequence "nics_id_seq" for serial column "nics.id" 
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "nics_pkey" for table "nics" 
   -> 0.0741s
-- add_index(:nics, [:type], {:name=>"index_by_type"})
   -> 0.0419s
-- add_index(:nics, [:host_id], {:name=>"index_by_host"})
   -> 0.0240s
-- add_index(:nics, [:type, :id], {:name=>"index_by_type_and_id"})
   -> 0.0240s
-- failed to import nics for kvmhost04.mgmt.rz01.riseops.at : PG::Error: ERROR:  current transaction is aborted, commands ignored until end of transaction block
:             SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
              FROM pg_attribute a LEFT JOIN pg_attrdef d
                ON a.attrelid = d.adrelid AND a.attnum = d.adnum
             WHERE a.attrelid = '"hosts"'::regclass
               AND a.attnum > 0 AND NOT a.attisdropped
             ORDER BY a.attnum
-- failed to import nics for kvmhost07.mgmt.rz01.riseops.at : PG::Error: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: SELECT  1 FROM "nics" WHERE ("nics"."mac" = '00:22:19:98:c5:98') LIMIT 1
-- failed to import nics for kvmhost06.mgmt.rz01.riseops.at : PG::Error: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: SELECT  1 FROM "nics" WHERE ("nics"."mac" = '00:22:19:98:bf:e7') LIMIT 1
-- failed to import nics for kvmhost05.mgmt.rz01.riseops.at : PG::Error: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: SELECT  1 FROM "nics" WHERE ("nics"."mac" = 'bc:30:5b:e5:91:dd') LIMIT 1
-- remove_columns(:hosts, :sp_mac, :sp_ip, :sp_name, :sp_subnet_id)
rake aborted!
An error has occurred, this and all later migrations canceled:

PG::Error: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: ALTER TABLE "hosts" DROP "sp_mac" 

Tasks: TOP => db:migrate
(See full trace by running task with --trace)

Here is the relevant portion of the Postgres server log:

2012-12-31 19:44:49 CET ERROR:  relation "locations_organizations" does not exist at character 580
2012-12-31 19:44:49 CET STATEMENT:            SELECT attr.attname, seq.relname
                  FROM pg_class      seq,
                       pg_attribute  attr,
                       pg_depend     dep,
                       pg_namespace  name,
                       pg_constraint cons
                  WHERE seq.oid           = dep.objid
                    AND seq.relkind       = 'S'
                    AND attr.attrelid     = dep.refobjid
                    AND attr.attnum       = dep.refobjsubid
                    AND attr.attrelid     = cons.conrelid
                    AND attr.attnum       = cons.conkey[1]
                    AND cons.contype      = 'p'
                    AND dep.refobjid      = '"locations_organizations"'::regclass

2012-12-31 19:44:49 CET ERROR:  current transaction is aborted, commands ignored until end of transaction block
2012-12-31 19:44:49 CET STATEMENT:            SELECT attr.attname, seq.relname
                  FROM pg_class      seq,
                       pg_attribute  attr,
                       pg_depend     dep,
                       pg_namespace  name,
                       pg_constraint cons
                  WHERE seq.oid           = dep.objid
                    AND seq.relkind       = 'S'
                    AND attr.attrelid     = dep.refobjid
                    AND attr.attnum       = dep.refobjsubid
                    AND attr.attrelid     = cons.conrelid
                    AND attr.attnum       = cons.conkey[1]
                    AND cons.contype      = 'p'
                    AND dep.refobjid      = '"locations_organizations"'::regclass

2012-12-31 19:44:49 CET ERROR:  current transaction is aborted, commands ignored until end of transaction block
2012-12-31 19:44:49 CET STATEMENT:              SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
                      FROM pg_attribute a LEFT JOIN pg_attrdef d
                        ON a.attrelid = d.adrelid AND a.attnum = d.adnum
                     WHERE a.attrelid = '"hosts"'::regclass
                       AND a.attnum > 0 AND NOT a.attisdropped
                     ORDER BY a.attnum

2012-12-31 19:44:49 CET ERROR:  current transaction is aborted, commands ignored until end of transaction block
2012-12-31 19:44:49 CET STATEMENT:  SELECT  1 FROM "nics" WHERE ("nics"."mac" = '00:22:19:98:c5:98') LIMIT 1
2012-12-31 19:44:49 CET ERROR:  current transaction is aborted, commands ignored until end of transaction block
2012-12-31 19:44:49 CET STATEMENT:  SELECT  1 FROM "nics" WHERE ("nics"."mac" = '00:22:19:98:bf:e7') LIMIT 1
2012-12-31 19:44:49 CET ERROR:  current transaction is aborted, commands ignored until end of transaction block
2012-12-31 19:44:49 CET STATEMENT:  SELECT  1 FROM "nics" WHERE ("nics"."mac" = 'bc:30:5b:e5:91:dd') LIMIT 1
2012-12-31 19:44:49 CET ERROR:  current transaction is aborted, commands ignored until end of transaction block
2012-12-31 19:44:49 CET STATEMENT:  ALTER TABLE "hosts" DROP "sp_mac" 

I am not even sure where exactly the first error occurs that causes the subsequent failures. If there is anything else I can provide, please do tell.

kvmhost04-foreman.png View kvmhost04-foreman.png 52.1 KB Network configuration of kvmhost04 Andreas Ntaflos, 01/01/2013 07:16 PM
Kvmhost04 foreman

Associated revisions

Revision adce9394 (diff)
Added by Ohad Levy over 9 years ago

fixes #2083 - DB migration fails with Postgres with bmc nics

History

#1 Updated by Ohad Levy over 9 years ago

can you add the output with --trace?

#2 Updated by Andreas Ntaflos over 9 years ago

Sure:

** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
==  CreateNics: migrating =====================================================
-- create_table(:nics)
NOTICE:  CREATE TABLE will create implicit sequence "nics_id_seq" for serial column "nics.id" 
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "nics_pkey" for table "nics" 
   -> 0.0461s
-- add_index(:nics, [:type], {:name=>"index_by_type"})
   -> 0.0234s
-- add_index(:nics, [:host_id], {:name=>"index_by_host"})
   -> 0.0295s
-- add_index(:nics, [:type, :id], {:name=>"index_by_type_and_id"})
   -> 0.0387s
-- failed to import nics for kvmhost04.mgmt.rz01.riseops.at : PG::Error: ERROR:  current transaction is aborted, commands ignored until end of transaction block
:             SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
              FROM pg_attribute a LEFT JOIN pg_attrdef d
                ON a.attrelid = d.adrelid AND a.attnum = d.adnum
             WHERE a.attrelid = '"hosts"'::regclass
               AND a.attnum > 0 AND NOT a.attisdropped
             ORDER BY a.attnum
-- failed to import nics for kvmhost07.mgmt.rz01.riseops.at : PG::Error: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: SELECT  1 FROM "nics" WHERE ("nics"."mac" = '00:22:19:98:c5:98') LIMIT 1
-- failed to import nics for kvmhost06.mgmt.rz01.riseops.at : PG::Error: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: SELECT  1 FROM "nics" WHERE ("nics"."mac" = '00:22:19:98:bf:e7') LIMIT 1
-- failed to import nics for kvmhost05.mgmt.rz01.riseops.at : PG::Error: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: SELECT  1 FROM "nics" WHERE ("nics"."mac" = 'bc:30:5b:e5:91:dd') LIMIT 1
-- remove_columns(:hosts, :sp_mac, :sp_ip, :sp_name, :sp_subnet_id)
rake aborted!
An error has occurred, this and all later migrations canceled:

PG::Error: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: ALTER TABLE "hosts" DROP "sp_mac" 
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/postgresql_adapter.rb:518:in `exec'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/postgresql_adapter.rb:518:in `execute'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/abstract_adapter.rb:202:in `log'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activesupport-3.0.17/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/abstract_adapter.rb:200:in `log'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/postgresql_adapter.rb:514:in `execute'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/abstract/schema_statements.rb:258:in `remove_columns'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/abstract/schema_statements.rb:257:in `each'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/abstract/schema_statements.rb:257:in `remove_columns'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:385:in `send'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:385:in `method_missing'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:361:in `say_with_time'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:361:in `say_with_time'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:381:in `method_missing'
/usr/local/share/foreman.1/db/migrate/20120311081257_create_nics.rb:33:in `up_without_benchmarks'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:314:in `send'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:314:in `migrate'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:314:in `migrate'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:397:in `__send__'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:397:in `migrate'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:539:in `migrate'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:613:in `call'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:613:in `ddl_transaction'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/transactions.rb:207:in `transaction'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:613:in `ddl_transaction'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:538:in `migrate'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:525:in `each'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:525:in `migrate'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:435:in `up'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:417:in `migrate'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/railties/databases.rake:151
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/task.rb:228:in `execute'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/task.rb:166:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/application.rb:101:in `top_level'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/application.rb:101:in `top_level'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/application.rb:73:in `run'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/bin/rake:33
/usr/local/share/foreman.1/vendor/ruby/1.8/bin/rake:23:in `load'
/usr/local/share/foreman.1/vendor/ruby/1.8/bin/rake:23
Tasks: TOP => db:migrate

#3 Updated by Ohad Levy over 9 years ago

do you have orgs turned on in your settings file?

#4 Updated by Ohad Levy over 9 years ago

can you try changing


diff --git a/db/migrate/20120311081257_create_nics.rb b/db/migrate/20120311081257_create_nics.rb
index a5a934c..7f7689c 100644
--- a/db/migrate/20120311081257_create_nics.rb
+++ b/db/migrate/20120311081257_create_nics.rb
@@ -1,5 +1,7 @@
 class CreateNics < ActiveRecord::Migration
-  class Host < ActiveRecord::Base; end
+  class Host < ActiveRecord::Base
+    has_many :interfaces, :dependent => :destroy, :inverse_of => :host, :class_name => 'Nic::Base'
+  end
   def self.up
     create_table :nics do |t|
       t.string :mac

#5 Updated by Ohad Levy over 9 years ago

I'm not able to reproduce this issue locally on PG.. can you try the patch above?

#6 Updated by Andreas Ntaflos over 9 years ago

Unfortunately that patch does not seem to have any effect, I get the same error messages (see below). I also have neither locations, nor organizations enabled in settings.yaml. It seems to me this isn't a Postgres issue, but something else, possibly and probably specific to our setup. What does the create_nics migration try to do? I have attached a screenshot of the network configuration for the problematic host (kvmhost04), in case that helps.

sudo -H -u foreman RAILS_ENV=production bundle exec rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
==  CreateNics: migrating =====================================================
-- create_table(:nics)
NOTICE:  CREATE TABLE will create implicit sequence "nics_id_seq" for serial column "nics.id" 
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "nics_pkey" for table "nics" 
   -> 0.0529s
-- add_index(:nics, [:type], {:name=>"index_by_type"})
   -> 0.0176s
-- add_index(:nics, [:host_id], {:name=>"index_by_host"})
   -> 0.0181s
-- add_index(:nics, [:type, :id], {:name=>"index_by_type_and_id"})
   -> 0.0180s
-- failed to import nics for kvmhost04.mgmt.rz01.riseops.at : PG::Error: ERROR:  current transaction is aborted, commands ignored until end of transaction block
:             SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
              FROM pg_attribute a LEFT JOIN pg_attrdef d
                ON a.attrelid = d.adrelid AND a.attnum = d.adnum
             WHERE a.attrelid = '"hosts"'::regclass
               AND a.attnum > 0 AND NOT a.attisdropped
             ORDER BY a.attnum
-- failed to import nics for kvmhost06.mgmt.rz01.riseops.at : PG::Error: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: SELECT  1 FROM "nics" WHERE ("nics"."mac" = '00:22:19:98:bf:e7') LIMIT 1
-- failed to import nics for kvmhost07.mgmt.rz01.riseops.at : PG::Error: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: SELECT  1 FROM "nics" WHERE ("nics"."mac" = '00:22:19:98:c5:98') LIMIT 1
-- failed to import nics for kvmhost05.mgmt.rz01.riseops.at : PG::Error: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: SELECT  1 FROM "nics" WHERE ("nics"."mac" = 'bc:30:5b:e5:91:dd') LIMIT 1
-- remove_columns(:hosts, :sp_mac, :sp_ip, :sp_name, :sp_subnet_id)
rake aborted!
An error has occurred, this and all later migrations canceled:

PG::Error: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: ALTER TABLE "hosts" DROP "sp_mac" 
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/postgresql_adapter.rb:518:in `exec'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/postgresql_adapter.rb:518:in `execute'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/abstract_adapter.rb:202:in `log'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activesupport-3.0.17/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/abstract_adapter.rb:200:in `log'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/postgresql_adapter.rb:514:in `execute'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/abstract/schema_statements.rb:258:in `remove_columns'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/abstract/schema_statements.rb:257:in `each'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/abstract/schema_statements.rb:257:in `remove_columns'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:385:in `send'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:385:in `method_missing'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:361:in `say_with_time'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:361:in `say_with_time'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:381:in `method_missing'
/usr/local/share/foreman.1/db/migrate/20120311081257_create_nics.rb:35:in `up_without_benchmarks'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:314:in `send'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:314:in `migrate'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:314:in `migrate'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:397:in `__send__'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:397:in `migrate'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:539:in `migrate'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:613:in `call'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:613:in `ddl_transaction'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/transactions.rb:207:in `transaction'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:613:in `ddl_transaction'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:538:in `migrate'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:525:in `each'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:525:in `migrate'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:435:in `up'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:417:in `migrate'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/railties/databases.rake:151
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/task.rb:228:in `execute'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/task.rb:166:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/application.rb:101:in `top_level'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/application.rb:101:in `top_level'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/application.rb:73:in `run'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/bin/rake:33
/usr/local/share/foreman.1/vendor/ruby/1.8/bin/rake:23:in `load'
/usr/local/share/foreman.1/vendor/ruby/1.8/bin/rake:23
Tasks: TOP => db:migrate

#7 Updated by Ohad Levy over 9 years ago

  • Category set to DB migrations
  • Target version set to 1.1

#8 Updated by Ohad Levy over 9 years ago

how about this then (sorry, as i simply can't reproduce) ? :)

diff --git a/db/migrate/20120311081257_create_nics.rb b/db/migrate/20120311081257_create_nics.rb
index a5a934c..6c32d31 100644
--- a/db/migrate/20120311081257_create_nics.rb
+++ b/db/migrate/20120311081257_create_nics.rb
@@ -18,6 +18,7 @@ class CreateNics < ActiveRecord::Migration
     add_index :nics, [:host_id], :name => 'index_by_host'
     add_index :nics, [:type, :id], :name => 'index_by_type_and_id'

+    Nic::Base.reset_column_information
     Host.where(["sp_mac <> ? and sp_ip <> ?", "", ""]).each do |host|
       begin
         sp_ip  = host.read_attribute(:sp_ip)

#9 Updated by Andreas Ntaflos over 9 years ago

Unfortunately it doesn't help :( Is there anything else I can do to debug this? Trying various patches is not a problem at all :)

** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
==  CreateNics: migrating =====================================================
-- create_table(:nics)
NOTICE:  CREATE TABLE will create implicit sequence "nics_id_seq" for serial column "nics.id" 
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "nics_pkey" for table "nics" 
   -> 0.0473s
-- add_index(:nics, [:type], {:name=>"index_by_type"})
   -> 0.0357s
-- add_index(:nics, [:host_id], {:name=>"index_by_host"})
   -> 0.0172s
-- add_index(:nics, [:type, :id], {:name=>"index_by_type_and_id"})
   -> 0.0179s
-- failed to import nics for kvmhost04.mgmt.rz01.riseops.at : PG::Error: ERROR:  current transaction is aborted, commands ignored until end of transaction block
:             SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
              FROM pg_attribute a LEFT JOIN pg_attrdef d
                ON a.attrelid = d.adrelid AND a.attnum = d.adnum
             WHERE a.attrelid = '"hosts"'::regclass
               AND a.attnum > 0 AND NOT a.attisdropped
             ORDER BY a.attnum
-- failed to import nics for kvmhost08.mgmt.rz01.riseops.at : PG::Error: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: SELECT  1 FROM "nics" WHERE ("nics"."mac" = '00:26:55:55:8a:96') LIMIT 1
-- failed to import nics for kvmhost06.mgmt.rz01.riseops.at : PG::Error: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: SELECT  1 FROM "nics" WHERE ("nics"."mac" = '00:22:19:98:bf:e7') LIMIT 1
-- failed to import nics for kvmhost07.mgmt.rz01.riseops.at : PG::Error: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: SELECT  1 FROM "nics" WHERE ("nics"."mac" = '00:22:19:98:c5:98') LIMIT 1
-- failed to import nics for kvmhost05.mgmt.rz01.riseops.at : PG::Error: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: SELECT  1 FROM "nics" WHERE ("nics"."mac" = 'bc:30:5b:e5:91:dd') LIMIT 1
-- remove_columns(:hosts, :sp_mac, :sp_ip, :sp_name, :sp_subnet_id)
rake aborted!
An error has occurred, this and all later migrations canceled:

PG::Error: ERROR:  current transaction is aborted, commands ignored until end of transaction block
: ALTER TABLE "hosts" DROP "sp_mac" 
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/postgresql_adapter.rb:518:in `exec'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/postgresql_adapter.rb:518:in `execute'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/abstract_adapter.rb:202:in `log'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activesupport-3.0.17/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/abstract_adapter.rb:200:in `log'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/postgresql_adapter.rb:514:in `execute'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/abstract/schema_statements.rb:258:in `remove_columns'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/abstract/schema_statements.rb:257:in `each'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/abstract/schema_statements.rb:257:in `remove_columns'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:385:in `send'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:385:in `method_missing'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:361:in `say_with_time'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:361:in `say_with_time'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:381:in `method_missing'
/usr/local/share/foreman.1/db/migrate/20120311081257_create_nics.rb:36:in `up_without_benchmarks'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:314:in `send'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:314:in `migrate'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:314:in `migrate'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:397:in `__send__'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:397:in `migrate'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:539:in `migrate'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:613:in `call'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:613:in `ddl_transaction'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/transactions.rb:207:in `transaction'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:613:in `ddl_transaction'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:538:in `migrate'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:525:in `each'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:525:in `migrate'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:435:in `up'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/migration.rb:417:in `migrate'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/activerecord-3.0.17/lib/active_record/railties/databases.rake:151
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/task.rb:228:in `execute'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/task.rb:166:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/application.rb:101:in `top_level'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/application.rb:101:in `top_level'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/application.rb:73:in `run'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/usr/local/share/foreman.1/vendor/ruby/1.8/gems/rake-10.0.3/bin/rake:33
/usr/local/share/foreman.1/vendor/ruby/1.8/bin/rake:23:in `load'
/usr/local/share/foreman.1/vendor/ruby/1.8/bin/rake:23
Tasks: TOP => db:migrate

#10 Updated by Ohad Levy over 9 years ago

here is another diff (from the current develop branch) :)

diff --git a/db/migrate/20120311081257_create_nics.rb b/db/migrate/20120311081257_create_nics.rb
index a5a934c..11a3aaa 100644
--- a/db/migrate/20120311081257_create_nics.rb
+++ b/db/migrate/20120311081257_create_nics.rb
@@ -1,5 +1,8 @@
 class CreateNics < ActiveRecord::Migration
   class Host < ActiveRecord::Base; end
+  class Subnet < ActiveRecord::Base
+    has_many :interfaces, :class_name => 'Nic::Base'
+  end
   def self.up
     create_table :nics do |t|
       t.string :mac
@@ -18,12 +21,14 @@ class CreateNics < ActiveRecord::Migration
     add_index :nics, [:host_id], :name => 'index_by_host'
     add_index :nics, [:type, :id], :name => 'index_by_type_and_id'

-    Host.where(["sp_mac <> ? and sp_ip <> ?", "", ""]).each do |host|
+    Nic::Base.reset_column_information
+    Host.unscoped.where(["sp_mac <> ? and sp_ip <> ?", "", ""]).each do |host|
       begin
         sp_ip  = host.read_attribute(:sp_ip)
         sp_mac = host.read_attribute(:sp_mac)
-          Nic::BMC.create! :host_id => host.id, :mac => sp_mac, :ip => sp_ip, :subnet_id => host.read_attribute(:sp_subnet_i
-            :name => host.read_attribute(:sp_name), :priority => 1
+          Nic::BMC.create! :host_id => host.id, :mac => sp_mac, :ip => sp_ip,
+                           :subnet_id => host.read_attribute(:sp_subnet_id),
+                           :name => host.read_attribute(:sp_name)
           say "created BMC interface for #{host}" 
       rescue => e
         say "failed to import nics for #{host} : #{e}" 

#11 Updated by Ohad Levy over 9 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF