question on repairDatabase

Showing 1-8 of 8 messages
question on repairDatabase Santosh 10/15/11 1:59 AM
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.
Re: question on repairDatabase Kristina Chodorow 10/17/11 5:03 PM
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()
> ...
Re: [mongodb-user] Re: question on repairDatabase Santosh 10/17/11 8:21 PM
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.


Re: question on repairDatabase Kristina Chodorow 10/18/11 6:59 AM
"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.
>
> On Tue, Oct 18, 2011 at 5:33 AM, Kristina Chodorow <k.chodo...@gmail.com>wrote:
Re: [mongodb-user] Re: question on repairDatabase Santosh 10/18/11 10:40 PM
Thanks for the information. So it is nothing related to any possible corruption.
Re: question on repairDatabase Kristina Chodorow 10/19/11 10:45 AM
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.
>
> On Tue, Oct 18, 2011 at 7:29 PM, Kristina Chodorow <k.chodo...@gmail.com>wrote:
Re: [mongodb-user] Re: question on repairDatabase Santosh 10/20/11 12:32 AM
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.

Re: [mongodb-user] Re: question on repairDatabase Eliot Horowitz 10/21/11 6:41 PM
the "ok" field will be 0 or false it is corrupt.