0
0
MongoDBquery~20 mins

Oplog and replication mechanism in MongoDB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Oplog Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What is the primary role of the oplog in MongoDB replication?

In MongoDB, the oplog is a special collection used in replication. What is its main purpose?

AIt stores a log of all write operations to replicate them to secondary nodes.
BIt manages network connections between replica set members.
CIt holds backup snapshots of the database for recovery.
DIt stores user authentication data for replica set members.
Attempts:
2 left
💡 Hint

Think about how changes are shared between primary and secondary nodes.

query_result
intermediate
2:00remaining
What does this oplog query return?

Consider this MongoDB query on the oplog collection:

db.oplog.rs.find({op: 'i'}).count()

What does this query return?

AThe number of update operations recorded in the oplog.
BThe number of insert operations recorded in the oplog.
CThe total number of operations in the oplog.
DThe number of delete operations recorded in the oplog.
Attempts:
2 left
💡 Hint

Look at the filter {op: 'i'} and what 'i' stands for in oplog entries.

📝 Syntax
advanced
2:00remaining
Identify the syntax error in this oplog query

Which option contains a syntax error when querying the oplog for update operations?

db.oplog.rs.find({op: 'u'})
Adb.oplog.rs.find({op: 'u'})
B)}'u' :po{(dnif.sr.golpo.bd
Cdb.oplog.rs.find({op = 'u'})
Db.oplog.rs.find({op: 'u'})
Attempts:
2 left
💡 Hint

Check the syntax for specifying query filters in MongoDB.

optimization
advanced
2:00remaining
How to optimize oplog size for a busy replica set?

You have a busy MongoDB replica set and want to optimize the oplog size to avoid losing operations during replication lag. Which approach is best?

ASet the oplog size to zero to use unlimited space.
BDecrease the oplog size to save disk space.
CDisable the oplog to improve write speed.
DIncrease the oplog size to hold more operations before overwriting.
Attempts:
2 left
💡 Hint

Think about how oplog size affects replication lag tolerance.

🔧 Debug
expert
3:00remaining
Why does this secondary node fail to replicate oplog entries?

A secondary node in a MongoDB replica set is not applying oplog entries and shows this error: Rollback due to missing oplog entries. What is the most likely cause?

AThe secondary's oplog window is too small and missed some operations.
BThe primary node is offline and not generating oplog entries.
CThe secondary has a network firewall blocking all traffic.
DThe secondary's oplog collection is corrupted and unreadable.
Attempts:
2 left
💡 Hint

Consider what happens if a secondary falls behind too much.