Search code examples
ruby-on-railsmongodbherokumlabmongoid4

Error when seeding mongoDB thru heroku


Hello I have an app that I built on heroku and I can’t seem to get the mlab DB to work. It seems to connect but when I run heroku run rake db:setup I get an error and can’t see what it is.

I upgraded to a paid account but that hasn’t fixed the problem. Please help me figure this out. Here is my mongoid.yml file

# Tell Mongoid which environment this configuration is for. 
production:   
  sessions:
  default:
  uri: <%= ENV['MONGOLAB_URI'] %>

development:   
  sessions:
  default:
  database: myapp_development
  hosts:
    - localhost:27017
  options:   options:

test:   
  sessions:
  default:
    database: myapp_test
    hosts:
      - localhost:27017
      options:
      read: primary
      max_retries: 1
      retry_interval: 0

My error is extremely long and I can’t seem to see the top lines but here is the top of what I can see.

/app/vendor/bundle/ruby/2.2.0/gems/moped-2.0.7/lib/moped/operation/read.rb:56:in `block (2 levels) in execute' /app/vendor/bundle/ruby/2.2.0/gems/moped-2.0.7/lib/moped/node.rb:118:in `block in connection' /app/vendor/bundle/ruby/2.2.0/gems/connection_pool-2.2.0/lib/connection_pool.rb:64:in `block (2 levels) in with' /app/vendor/bundle/ruby/2.2.0/gems/connection_pool-2.2.0/lib/connection_pool.rb:63:in `handle_interrupt' /app/vendor/bundle/ruby/2.2.0/gems/connection_pool-2.2.0/lib/connection_pool.rb:63:in `block in with' /app/vendor/bundle/ruby/2.2.0/gems/connection_pool-2.2.0/lib/connection_pool.rb:60:in `handle_interrupt' /app/vendor/bundle/ruby/2.2.0/gems/connection_pool-2.2.0/lib/connection_pool.rb:60:in `with' /app/vendor/bundle/ruby/2.2.0/gems/moped-2.0.7/lib/moped/node.rb:116:in `connection' /app/vendor/bundle/ruby/2.2.0/gems/moped-2.0.7/lib/moped/operation/read.rb:52:in `block in execute' /app/vendor/bundle/ruby/2.2.0/gems/moped-2.0.7/lib/moped/node.rb:608:in `[]' /app/vendor/bundle/ruby/2.2.0/gems/moped-2.0.7/lib/moped/node.rb:608:in `block (3 levels) in flush’

Thanks for any help.

BTW I am running mongoid 4.0.2 and rails 2.2.1

--UPDATE--

I ran heroku run rake --trace db:setup

I got this response...

Running rake --trace db:setup on truenumbers-beta.... up, run.9099 ** Invoke db:setup (first_time) ** Invoke db:create (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:create ** Invoke db:mongoid:create_indexes (first_time) ** Invoke environment ** Invoke db:mongoid:load_models (first_time) ** Execute db:mongoid:load_models ** Execute db:mongoid:create_indexes D, [2016-03-29T19:51:17.573001 #3] DEBUG -- : MOPED: 10.164.48.254:11460 COMMAND database=admin command={:ismaster=>1} runtime: 15.4384ms D, [2016-03-29T19:51:17.594073 #3] DEBUG -- : MOPED: 10.158.94.215:11460 COMMAND database=admin command={:ismaster=>1} runtime: 10.7151ms D, [2016-03-29T19:51:17.611470 #3] DEBUG -- : MOPED: 10.164.48.254:11460 COMMAND database=heroku_q1xh85jr command={:getlasterror=>1, :w=>1} runtime: 1.3616ms D, [2016-03-29T19:51:17.611875 #3] DEBUG -- : MOPED: 10.164.48.254:11460 INSERT database=heroku_...db collection=system.indexes documents=[{:ns=>"heroku_...db.fs.files", :key=>{:filename=>1}, :name=>"filename_1"}] flags=[] D, [2016-03-29T19:51:17.611965 #3] DEBUG -- : COMMAND database=heroku_...db command={:getlasterror=>1, :w=>1} runtime: 10.7461ms D, [2016-03-29T19:51:17.618998 #3] DEBUG -- : MOPED: 10.164.48.254:11460 COMMAND database=heroku_...db command={:getlasterror=>1, :w=>1} runtime: 2.2909ms D, [2016-03-29T19:51:17.619499 #3] DEBUG -- : MOPED: 10.164.48.254:11460 INSERT database=heroku_...db collection=system.indexes documents=[{:ns=>"heroku_...db.fs.files", :key=>{:aliases=>1}, :name=>"aliases_1"}] flags=[] D, [2016-03-29T19:51:17.619588 #3] DEBUG -- : COMMAND database=heroku_...db command={:getlasterror=>1, :w=>1} runtime: 6.9291ms D, [2016-03-29T19:51:17.635347 #3] DEBUG -- : MOPED: 10.164.48.254:11460 COMMAND database=heroku_...db command={:getlasterror=>1, :w=>1} runtime: 1.2759ms D, [2016-03-29T19:51:17.635548 #3] DEBUG -- : MOPED: 10.164.48.254:11460 INSERT database=heroku_...db collection=system.indexes documents=[{:ns=>"heroku_...db.fs.files", :key=>{:uploadDate=>1}, :name=>"uploadDate_1"}] flags=[] D, [2016-03-29T19:51:17.635637 #3] DEBUG -- : COMMAND database=heroku_...db command={:getlasterror=>1, :w=>1} runtime: 15.4409ms D, [2016-03-29T19:51:17.641401 #3] DEBUG -- : MOPED: 10.164.48.254:11460 COMMAND database=heroku_...db command={:getlasterror=>1, :w=>1} runtime: 1.2005ms D, [2016-03-29T19:51:17.641598 #3] DEBUG -- : MOPED: 10.164.48.254:11460 INSERT database=heroku_...db collection=system.indexes documents=[{:ns=>"heroku_...db.fs.files", :key=>{:md5=>1}, :name=>"md5_1"}] flags=[] D, [2016-03-29T19:51:17.641683 #3] DEBUG -- : COMMAND database=heroku_...db command={:getlasterror=>1, :w=>1} runtime: 5.4224ms I, [2016-03-29T19:51:17.641804 #3] INFO -- : MONGOID: Created indexes on Mongoid::GridFs::Fs::File: I, [2016-03-29T19:51:17.641914 #3] INFO -- : MONGOID: Index: {:filename=>1}, Options: {} I, [2016-03-29T19:51:17.641988 #3] INFO -- : MONGOID: Index: {:aliases=>1}, Options: {} I, [2016-03-29T19:51:17.642066 #3] INFO -- : MONGOID: Index: {:uploadDate=>1}, Options: {} I, [2016-03-29T19:51:17.642166 #3] INFO -- : MONGOID: Index: {:md5=>1}, Options: {} D, [2016-03-29T19:51:17.648954 #3] DEBUG -- : MOPED: 10.164.48.254:11460 COMMAND database=heroku_...db command={:getlasterror=>1, :w=>1} runtime: 1.1073ms D, [2016-03-29T19:51:17.649090 #3] DEBUG -- : MOPED: 10.164.48.254:11460 INSERT database=heroku_...db collection=system.indexes documents=[{:unique=>true, :ns=>"heroku_...db.fs.chunks", :key=>{:files_id=>1, :n=>-1}, :name=>"files_id_1_n_-1"}] flags=[] D, [2016-03-29T19:51:17.649137 #3] DEBUG -- : COMMAND database=heroku_...db command={:getlasterror=>1, :w=>1} runtime: 5.3409ms I, [2016-03-29T19:51:17.649182 #3] INFO -- : MONGOID: Created indexes on Mongoid::GridFs::Fs::Chunk: I, [2016-03-29T19:51:17.649234 #3] INFO -- : MONGOID: Index: {:files_id=>1, :n=>-1}, Options: {:unique=>true} D, [2016-03-29T19:51:17.656835 #3] DEBUG -- : MOPED: 10.164.48.254:11460 COMMAND database=heroku_...db command={:getlasterror=>1, :w=>1} runtime: 1.0796ms D, [2016-03-29T19:51:17.656969 #3] DEBUG -- : MOPED: 10.164.48.254:11460 INSERT database=heroku_...db collection=system.indexes documents=[{:background=>true, :ns=>"heroku_...db.tenants", :key=>{:invitation_token=>1}, :name=>"invitation_token_1"}] flags=[] D, [2016-03-29T19:51:17.657016 #3] DEBUG -- : COMMAND database=heroku_...db command={:getlasterror=>1, :w=>1} runtime: 7.2313ms D, [2016-03-29T19:51:17.663727 #3] DEBUG -- : MOPED: 10.164.48.254:11460 COMMAND database=heroku_...db command={:getlasterror=>1, :w=>1} runtime: 1.1747ms D, [2016-03-29T19:51:17.663903 #3] DEBUG -- : MOPED: 10.164.48.254:11460 INSERT database=heroku_...db collection=system.indexes documents=[{:background=>true, :ns=>"heroku_...db.tenants", :key=>{:invitation_by_id=>1}, :name=>"invitation_by_id_1"}] flags=[] D, [2016-03-29T19:51:17.663989 #3] DEBUG -- : COMMAND database=heroku_...db command={:getlasterror=>1, :w=>1} runtime: 6.2813ms I, [2016-03-29T19:51:17.664065 #3] INFO -- : MONGOID: Created indexes on Tenant: I, [2016-03-29T19:51:17.664166 #3] INFO -- : MONGOID: Index: {:invitation_token=>1}, Options: {:background=>true} I, [2016-03-29T19:51:17.664240 #3] INFO -- : MONGOID: Index: {:invitation_by_id=>1}, Options: {:background=>true} D, [2016-03-29T19:51:17.672419 #3] DEBUG -- : MOPED: 10.164.48.254:11460 COMMAND database=heroku_...db command={:getlasterror=>1, :w=>1} runtime: 1.3468ms D, [2016-03-29T19:51:17.672824 #3] DEBUG -- : MOPED: 10.164.48.254:11460 INSERT database=heroku_...db collection=system.indexes documents=[{:background=>true, :ns=>"heroku_...db.managers", :key=>{:invitation_token=>1}, :name=>"invitation_token_1"}] flags=[] D, [2016-03-29T19:51:17.672911 #3] DEBUG -- : COMMAND database=heroku_...db command={:getlasterror=>1, :w=>1} runtime: 7.8967ms D, [2016-03-29T19:51:17.679652 #3] DEBUG -- : MOPED: 10.164.48.254:11460 COMMAND database=heroku_...db command={:getlasterror=>1, :w=>1} runtime: 1.7443ms D, [2016-03-29T19:51:17.679844 #3] DEBUG -- : MOPED: 10.164.48.254:11460 INSERT database=heroku_...db collection=system.indexes documents=[{:background=>true, :ns=>"heroku_...db.managers", :key=>{:invitation_by_id=>1}, :name=>"invitation_by_id_1"}] flags=[] D, [2016-03-29T19:51:17.680187 #3] DEBUG -- : COMMAND database=heroku_...db command={:getlasterror=>1, :w=>1} runtime: 6.4280ms I, [2016-03-29T19:51:17.681679 #3] INFO -- : MONGOID: Created indexes on Manager: I, [2016-03-29T19:51:17.682260 #3] INFO -- : MONGOID: Index: {:invitation_token=>1}, Options: {:background=>true} I, [2016-03-29T19:51:17.682339 #3] INFO -- : MONGOID: Index: {:invitation_by_id=>1}, Options: {:background=>true} D, [2016-03-29T19:51:17.690098 #3] DEBUG -- : MOPED: 10.164.48.254:11460 COMMAND database=heroku_...db command={:getlasterror=>1, :w=>1} runtime: 2.1209ms D, [2016-03-29T19:51:17.698085 #3] DEBUG -- : MOPED: 10.164.48.254:11460 INSERT database=heroku_...db collection=system.indexes documents=[{:background=>true, :ns=>"heroku_...db.blog_posts", :key=>{:tags=>1}, :name=>"tags_1"}] flags=[] D, [2016-03-29T19:51:17.698350 #3] DEBUG -- : COMMAND database=heroku_...db command={:getlasterror=>1, :w=>1} runtime: 14.8885ms D, [2016-03-29T19:51:17.714160 #3] DEBUG -- : MOPED: 10.164.48.254:11460 COMMAND database=heroku_...db command={:getlasterror=>1, :w=>1} runtime: 8.2012ms D, [2016-03-29T19:51:17.715702 #3] DEBUG -- : MOPED: 10.164.48.254:11460 INSERT database=heroku_...db collection=system.indexes documents=[{:background=>true, :ns=>"heroku_...db.blog_posts", :key=>{:keywords=>1}, :name=>"keywords_1"}] flags=[] D, [2016-03-29T19:51:17.715800 #3] DEBUG -- : COMMAND database=heroku_...db command={:getlasterror=>1, :w=>1} runtime: 16.5160ms D, [2016-03-29T19:51:17.731378 #3] DEBUG -- : MOPED: 10.164.48.254:11460 COMMAND database=heroku_...db command={:getlasterror=>1, :w=>1} runtime: 6.8590ms D, [2016-03-29T19:51:17.732511 #3] DEBUG -- : MOPED: 10.164.48.254:11460 INSERT database=heroku_...db collection=system.indexes documents=[{:background=>true, :ns=>"heroku_...db.blog_posts", :key=>{:type=>1}, :name=>"type_1"}] flags=[] D, [2016-03-29T19:51:17.732602 #3] DEBUG -- : COMMAND database=heroku_...db command={:getlasterror=>1, :w=>1} runtime: 15.9511ms I, [2016-03-29T19:51:17.732759 #3] INFO -- : MONGOID: Created indexes on Blog::Post: I, [2016-03-29T19:51:17.732872 #3] INFO -- : MONGOID: Index: {:tags=>1}, Options: {:background=>true} I, [2016-03-29T19:51:17.732999 #3] INFO -- : MONGOID: Index: {:keywords=>1}, Options: {:background=>true} I, [2016-03-29T19:51:17.733300 #3] INFO -- : MONGOID: Index: {:type=>1}, Options: {:background=>true} ** Invoke db:seed (first_time) ** Invoke environment ** Execute db:seed D, [2016-03-29T19:51:23.970070 #3] DEBUG -- : MOPED: 10.164.48.254:11460 QUERY database=heroku_...db collection=tenants selector={"email"=>"[email protected]"} flags=[] limit=-1 skip=0 batch_size=nil fields={:_id=>1} runtime: 4.9172ms

It seems to be creating the db but not able to seed it. However when I go and look at the db nothing is their which makes me think maybe it starts building the db and when the seed fails it destroys what it did.


Solution

  • The problem turned out to be that the DB I was using in development was an older version of MongoDB. I upgraded to MongoDB 5 and everything worked after a little revision.