question on repairDatabase

52 views
Skip to first unread message

Santosh c

unread,
Oct 15, 2011, 4:59:09 AM10/15/11
to mongodb-user
Hi,

My database was corrupt and I repaired it. The repair did not give an additional message, does it mean there was no data lost due to corruption.

If not, is there any other way to check sanity of the data?

db.stats()
{ "errmsg" : "exception: assertion db/pdfile.h:259", "code" : 0, "ok" : 0 }
> db.repairDatabase()
{ "ok" : 1 }


thanks.

Kristina Chodorow

unread,
Oct 17, 2011, 8:03:17 PM10/17/11
to mongodb-user
Repair will print messages in the server log if it had to remove
records. Remember that you have to run repair for each db.

You can use validate() on each collection to check sanity, e.g.:

> db.coll1.validate()
> db.coll2.validate()
> db.coll3.validate()
> ...

Santosh c

unread,
Oct 17, 2011, 11:21:33 PM10/17/11
to mongod...@googlegroups.com
Thanks for the response. I remember watching the server log carefully while the repair was going on (/var/log/mongodb/mongod.log) and I didnt see anything that said "remove", or at least I dont remember now.
 
I ran validate on one collection now, although it says ok:1 and valid:true, it also says deleted: n: <n>, size: <size>, what does this represent? The doc at http://www.mongodb.org/display/DOCS/Validate+Command doesnt explain the result parameters.
 
thanks again.

--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.


Kristina Chodorow

unread,
Oct 18, 2011, 9:59:29 AM10/18/11
to mongodb-user
"deletedCount" is the number of records on the free list (and is
always at least 1). So, if you inserted five docs and deleted two,
"deleted" would be 3 (1+2). If you then inserted a smaller record
that could fit in the free space left by deleting a record, "deleted"
will go down to 2. E.g.:

> db.foo.insert({_id:1,"foo":"bar"})
> db.foo.insert({_id:2,"foo":"bar"})
> db.foo.insert({_id:3,"foo":"bar"})
> db.foo.insert({_id:4,"foo":"bar"})
> db.foo.insert({_id:5,"foo":"bar"})
> db.foo.validate().deletedCount
1
> db.foo.remove({_id:1})
> db.foo.remove({_id:2})
> db.foo.validate().deletedCount
3
> db.foo.insert({_id:2})
> db.foo.validate().deletedCount
2


On Oct 17, 11:21 pm, Santosh c <santoshc...@gmail.com> wrote:
> Thanks for the response. I remember watching the server log carefully while
> the repair was going on (/var/log/mongodb/mongod.log) and I didnt see
> anything that said "remove", or at least I dont remember now.
>
> I ran validate on one collection now, although it says ok:1 and valid:true,
> it also says deleted: n: <n>, size: <size>, what does this represent? The
> doc athttp://www.mongodb.org/display/DOCS/Validate+Commanddoesnt explain
> the result parameters.
>
> thanks again.
>

Santosh c

unread,
Oct 19, 2011, 1:40:55 AM10/19/11
to mongod...@googlegroups.com
Thanks for the information. So it is nothing related to any possible corruption.

Kristina Chodorow

unread,
Oct 19, 2011, 1:45:54 PM10/19/11
to mongodb-user
Correct.


On Oct 19, 1:40 am, Santosh c <santoshc...@gmail.com> wrote:
> Thanks for the information. So it is nothing related to any possible
> corruption.
>

Santosh c

unread,
Oct 20, 2011, 3:32:12 AM10/20/11
to mongod...@googlegroups.com
Sorry to keep coming back to you, but is there an example of what validate() will say when the collection is indeed corrupt?
 
That is, what all things can possible go wrong in the collection.

Eliot Horowitz

unread,
Oct 21, 2011, 9:41:19 PM10/21/11
to mongod...@googlegroups.com
the "ok" field will be 0 or false it is corrupt.
Reply all
Reply to author
Forward
0 new messages