Group Discounts available for 3+ students and Corporate Clients

MongoDB Interview Questions and Answers

How long does replica set fail over take?

It may take 10-30 seconds for the primary to be declared down by the other members and a new primary elected. During this window of time, the cluster is down for “primary” operations – that is, writes and strong consistent reads. However, you may execute eventually consistent queries to secondaries at any time (in slaveOk mode), including during this window.

Do I have to call getLastError to make a write durable?

No. If you don’t call getLastError (aka “Safe Mode”) the server does exactly the same behavior as if you had. The getLastError call simply lets one get confirmation that the write operation was successfully committed. Of course, often you will want that confirmation, but the safety of the write and its durability is independent.

Should I start out with sharded or with a non-shared MongoDB environment?

We suggest starting unshared for simplicity and quick startup unless your initial data set will not fit on single servers. Upgrading to sharding from unshared is easy and seamless, so there is not a lot of advantage to setting up sharing before your data set is large.

Learn more about Mongo DB Interview Questions in this blog post.
Interested in mastering Mongo DB? 
Check out this blog post to learn more Mongo DB Tutorials.

What happens if I try to update a document on a chunk that is being migrated?

The update will go through immediately on the old shard, and then the change will be replicated to the new shard before ownership transfers.

What if a shard is down or slow and I do a query?

If a shard is down, the query will return an error unless the “Partial” query options is set. If a shard is responding slowly, mongos will wait for it.

Can I remove old files in the moveChunk directory?

Yes, these files are made as backups during normal shard balancing operations. Once the operations are done then they can be deleted. The cleanup process is currently manual so please do take care of this to free up space.

How can I see the connections used by mongos?

db._adminCommand("connPoolStats");

If a moveChunk fails do I need to cleanup the partially moved docs?

No, chunk moves are consistent and deterministic; the move will retry and when completed the data will only be on the new shard.

What makes Mongodb best?

  • Document-oriented
  • High performance
  • High availability
  • Easy scalability
  • Rich query language

What is 32 bit nuances?

There is extra memory mapped file activity with journaling. This will further constrain the limited db size of 32 bit builds. Thus, for now journaling by default is disabled on 32 bit systems.

Will the journal replay have problems if entries are incomplete (like the failure happened in the middle of one)?

Each journal (group) write is consistent and won’t be replayed during recovery unless it is complete.

Are null values allowed?

For members of an object, yes. You cannot add null to a database collection though as null isn’t an object. You can add {}, though.

What’s a master or primary?

This is a node/member which is currently the primary and processes all writes for the replica set. In a replica set, on a failover event, a different member can become primary.

What’s a secondary or slave?

A secondary is a node/member which applies operations from the current primary. This is done by tailing the replication oplog (local.oplog.rs).

Replication from primary to secondary is asynchronous, however the secondary will try to stay as close to current as possible (often this is just a few milliseconds on a LAN).

Do I have to call getLastError to make a write durable?

No. If you don’t call getLastError (aka “Safe Mode”) the server does exactly the same behavior as if you had. The getLastError call simply lets one get confirmation that the write operation was successfully committed. Of course, often you will want that confirmation, but the safety of the write and its durability is independent.

Should I start out with sharded or with a non-sharded MongoDB environment?

We suggest starting unsharded for simplicity and quick startup unless your initial data set will not fit on single servers. Upgrading to sharing from unshared is easy and seamless, so there is not a lot of advantage to setting up sharing before your data set is large.

For indepth understanding click on

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on MongoDB Interview Questions and Answers"

    Leave a Message

    Your email address will not be published. Required fields are marked *

    Support


    Please Enter Your Details and Query.
    Three + 6