Haven't change my code for some time, and it was working fine. But started yesterday, I found I can't save my new record to the mongod db via mongoid.
Background:
gem 'rails', '3.2.5'
gem 'mongo', "1.6.2"
gem "mongoid", "2.4.7"
mongo server version: db version v2.0.5, pdfile version 4.5 MongoDB shell version: 2.0.5
rails models and data size (still in development mode): 3 models (users: 164K, relation: 122M, status:370K)
Problem: Can't save new users records, as showing here, even it passed the contraints (like I have unique uid, id_str).
[2] pry(main)> User.count
=> 164325
[3] pry(main)> u=User.new(uid: 1001, id_str: "1001")
=> #<User _id: 501452f346b0a14fb5000001, _type: nil, created_at: nil, updated_at: nil, uid: 1001, id_str: "1001", name: nil, screen_name: nil, location: nil>
[4] pry(main)> u.save
=> true
[5] pry(main)> User.count
=> 164325
[6] pry(main)> u.save!
=> true
[7] pry(main)> User.count
=> 164325
Rails log file:
MONGODB (0ms) blog_development['$cmd'].find({"count"=>"users", "query"=>{}, "fields"=>nil}).limit(-1)
MONGODB (0ms) blog_development['users'].insert([{"_id"=>BSON::ObjectId('501452f346b0a14fb5000001'), "uid"=>1001, "id_str"=>"1001", "updated_at"=>2012-07-28 21:00:39 UTC, "created_at"=>2012-07-28 21:00:39 UTC}])
MONGODB (0ms) blog_development['$cmd'].find({"count"=>"users", "query"=>{}, "fields"=>nil}).limit(-1)
MONGODB (0ms) blog_development['$cmd'].find({"count"=>"users", "query"=>{}, "fields"=>nil}).limit(-1)
Nothing in the mongodb.log file as the operation is so fast
What could be the reason causing the not-saving issue?
updates: My db status in mongo shell:
"ns" : "blog_development.users",
"count" : 164325,
"size" : 159656080,
"avgObjSize" : 971.5872813022972,
"storageSize" : 177336320,
"numExtents" : 14,
"nindexes" : 3,
"lastExtentSize" : 36089856,
"paddingFactor" : 1.0099999999963194,
"flags" : 1,
"totalIndexSize" : 22729280,
"indexSizes" : {
"_id_" : 9598624,
"uid_1" : 6091120,
"screen_name_1" : 7039536
},
"ok" : 1
os is: 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:24 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
db.users.stats()look like? and what O/S are you using?