Search code examples
ruby-on-railspostgresqljruby

ActiveRecord::JDBCError: ERROR: could not open extension control file


This may be a chair to Google interface issue but I am not able to uncover anything yet. Any pointers would be helpful.

JRuby 1.6.8 Rails 3.2.11 Postgres 9.1 Ubuntu 12.04

I have a RAILS Migration:

class AddDblinkToEnrollmentsShards < ActiveRecord::Migration
  db_magic :connections => [:enrollments_shard_one, :enrollments_shard_two, :enrollments_shard_three, :enrollments_shard_four]

  def change
    execute "CREATE EXTENSION IF NOT EXISTS dblink WITH SCHEMA public;"
  end
end

And I keep getting this error:

-- execute("CREATE EXTENSION IF NOT EXISTS dblink WITH SCHEMA public;")
  [enrollments_shard_one]   (16.0ms)  CREATE EXTENSION IF NOT EXISTS dblink WITH SCHEMA public;
ActiveRecord::JDBCError: ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/dblink.control": No such file or directory: CREATE EXTENSION IF NOT EXISTS dblink WITH SCHEMA public;
==  AddDblinkToEnrollmentsShards: Switching connection back ===================
rake aborted!
An error has occurred, this and all later migrations canceled:

ActiveRecord::JDBCError: ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/dblink.control": No such file or directory: CREATE EXTENSION IF NOT EXISTS dblink WITH SCHEMA public;
arjdbc/jdbc/RubyJdbcConnection.java:195:in `execute'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-jdbc-adapter-1.2.5/lib/arjdbc/jdbc/adapter.rb:217:in `_execute'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-jdbc-adapter-1.2.5/lib/arjdbc/jdbc/adapter.rb:209:in `execute'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `log'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activesupport-3.2.11/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/bundler/gems/db-charmer-f12baa3d23aa/lib/db_charmer/rails3/abstract_adapter/connection_name.rb:14:in `instrument'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/newrelic_rpm-3.5.6.46/lib/new_relic/agent/instrumentation/active_record.rb:32:in `log_with_newrelic_instrumentation'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/newrelic_rpm-3.5.6.46/lib/new_relic/agent/method_tracer.rb:240:in `trace_execution_scoped'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/newrelic_rpm-3.5.6.46/lib/new_relic/agent/instrumentation/active_record.rb:29:in `log_with_newrelic_instrumentation'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-jdbc-adapter-1.2.5/lib/arjdbc/jdbc/adapter.rb:209:in `execute'
org/jruby/RubyBasicObject.java:1704:in `__send__'
org/jruby/RubyKernel.java:2130:in `send'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:466:in `method_missing'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:438:in `say_with_time'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:438:in `say_with_time'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:458:in `method_missing'
/home/scott/source/unicon/unicon-ttm-sandbox/db/migrate/20130103134257_add_dblink_to_enrollments_shards.rb:5:in `change'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:407:in `migrate'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:407:in `migrate'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:129:in `with_connection'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:389:in `migrate'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/bundler/gems/db-charmer-f12baa3d23aa/lib/db_charmer/active_record/migration/multi_db_migrations.rb:86:in `migrate_with_db_wrapper'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/bundler/gems/db-charmer-f12baa3d23aa/lib/db_charmer/active_record/migration/multi_db_migrations.rb:125:in `on_db'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:129:in `with_connection'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/bundler/gems/db-charmer-f12baa3d23aa/lib/db_charmer/active_record/migration/multi_db_migrations.rb:123:in `on_db'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/bundler/gems/db-charmer-f12baa3d23aa/lib/db_charmer/active_record/migration/multi_db_migrations.rb:85:in `migrate_with_db_wrapper'
org/jruby/RubyArray.java:1620:in `each'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/bundler/gems/db-charmer-f12baa3d23aa/lib/db_charmer/active_record/migration/multi_db_migrations.rb:84:in `migrate_with_db_wrapper'
org/jruby/RubyBasicObject.java:1704:in `__send__'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:528:in `migrate'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:720:in `migrate'
org/jruby/RubyProc.java:258:in `call'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:775:in `ddl_transaction'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/transactions.rb:208:in `transaction'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/newrelic_rpm-3.5.6.46/lib/new_relic/agent/method_tracer.rb:491:in `transaction_with_trace_ActiveRecord_self_name_transaction'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/newrelic_rpm-3.5.6.46/lib/new_relic/agent/method_tracer.rb:240:in `trace_execution_scoped'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/newrelic_rpm-3.5.6.46/lib/new_relic/agent/method_tracer.rb:486:in `transaction_with_trace_ActiveRecord_self_name_transaction'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:775:in `ddl_transaction'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:719:in `migrate'
org/jruby/RubyArray.java:1620:in `each'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:700:in `migrate'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:570:in `up'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/migration.rb:557:in `migrate'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:179:in `(root)'
org/jruby/RubyProc.java:258:in `call'
org/jruby/RubyArray.java:1620:in `each'
org/jruby/RubyArray.java:1620:in `each'
org/jruby/RubyKernel.java:1097:in `load'
org/jruby/RubyKernel.java:1117:in `eval'
/home/scott/.rvm/gems/jruby-1.6.8@jruby168-unicon/bin/ruby_noexec_wrapper:14:in `(root)'

Solution

  • The dblink extension was not installed with the main PostgreSQL package on this system, so the user had to install it separately. See comments.