Note that there are some explanatory texts on larger screens.

plurals
  1. POcan not save new record to my rails model using mongoid and MongoDB
    primarykey
    data
    text
    <p>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.</p> <p>Background:</p> <pre><code>gem 'rails', '3.2.5' gem 'mongo', "1.6.2" gem "mongoid", "2.4.7" </code></pre> <p>mongo server version: db version v2.0.5, pdfile version 4.5 MongoDB shell version: 2.0.5</p> <p>rails models and data size (still in development mode): 3 models (users: 164K, relation: 122M, status:370K)</p> <p>Problem: Can't save new users records, as showing here, even it passed the contraints (like I have unique uid, id_str).</p> <pre><code>[2] pry(main)&gt; User.count =&gt; 164325 [3] pry(main)&gt; u=User.new(uid: 1001, id_str: "1001") =&gt; #&lt;User _id: 501452f346b0a14fb5000001, _type: nil, created_at: nil, updated_at: nil, uid: 1001, id_str: "1001", name: nil, screen_name: nil, location: nil&gt; [4] pry(main)&gt; u.save =&gt; true [5] pry(main)&gt; User.count =&gt; 164325 [6] pry(main)&gt; u.save! =&gt; true [7] pry(main)&gt; User.count =&gt; 164325 </code></pre> <p>Rails log file:</p> <pre><code>MONGODB (0ms) blog_development['$cmd'].find({"count"=&gt;"users", "query"=&gt;{}, "fields"=&gt;nil}).limit(-1) MONGODB (0ms) blog_development['users'].insert([{"_id"=&gt;BSON::ObjectId('501452f346b0a14fb5000001'), "uid"=&gt;1001, "id_str"=&gt;"1001", "updated_at"=&gt;2012-07-28 21:00:39 UTC, "created_at"=&gt;2012-07-28 21:00:39 UTC}]) MONGODB (0ms) blog_development['$cmd'].find({"count"=&gt;"users", "query"=&gt;{}, "fields"=&gt;nil}).limit(-1) MONGODB (0ms) blog_development['$cmd'].find({"count"=&gt;"users", "query"=&gt;{}, "fields"=&gt;nil}).limit(-1) </code></pre> <p>Nothing in the mongodb.log file as the operation is so fast</p> <p>What could be the reason causing the not-saving issue?</p> <p>updates: My db status in mongo shell:</p> <pre><code>"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 </code></pre> <p>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</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload