MongoDB Locking Mechanism during chunk move

205 views
Skip to first unread message

Mainak Ghosh

unread,
Oct 23, 2012, 10:54:06 AM10/23/12
to mongod...@googlegroups.com
Hi,

I was looking into mongodb code and could not fathom this. I want to know whether during mongodb chunk movement, by the balancer, writes to that chunk are locked. I could not find any evidence for this. Does anybody know about this and can point me to the piece of code which does this?

In case mongodb does not lock writes, then how does the write happen while the chunk is migrated. Is it like we use the oplog somehow or do we change the key value in place within the chunks without worrying about consistency? By oplog what I mean is all writes to that chunk are cached and are played out once the chunk has been completely migrated.

Thanks for you replies.

Mainak.

Jenna deBoisblanc

unread,
Oct 23, 2012, 11:45:56 AM10/23/12
to mongod...@googlegroups.com
Hello Mainak,

Any writes to a chunk that take place while the chunk is migrating will be flagged, and before the migration is complete, the balancer will ensure that these documents reside on the correct shard.  For additional details and information about this process, please refer to the following presentation:

Mainak Ghosh

unread,
Oct 31, 2012, 11:46:13 AM10/31/12
to mongod...@googlegroups.com
Hi,

Thanks Jenna. I think now I understand the mechanism a little more but I have been unsuccessful in finding the piece of code which does rounds of data transfer and on failing to converge splits the chunk. Anybody comfortable with the mongo code enough who can help me on this.

Thanks and Regards,
Mainak

Jenna deBoisblanc

unread,
Nov 7, 2012, 10:57:54 AM11/7/12
to mongod...@googlegroups.com
Hello Mainak,

I believe the writebacklisten thread is responsible for catching these documents, so as a starting point, you may want to grep the source code for this word.
Reply all
Reply to author
Forward
0 new messages