0
0
MongoDBquery~20 mins

Primary and secondary nodes in MongoDB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Replica Set Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Role of Primary Node in MongoDB Replica Set

In a MongoDB replica set, what is the main responsibility of the primary node?

AIt balances the load by distributing read requests among all nodes.
BIt only stores backup data and does not accept any client requests.
CIt handles all write operations and replicates data to secondary nodes.
DIt monitors network traffic but does not store any data.
Attempts:
2 left
💡 Hint

Think about which node accepts changes and shares them with others.

query_result
intermediate
2:00remaining
Identifying the Primary Node with rs.status()

Given the output of rs.status() command in MongoDB, which field indicates the primary node?

MongoDB
rs.status()
AThe member with "stateStr" value "PRIMARY"
BThe member with "health" value 0
CThe member with "stateStr" value "SECONDARY"
DThe member with "optimeDate" set to null
Attempts:
2 left
💡 Hint

Look for the status string that explicitly says which node is primary.

📝 Syntax
advanced
2:00remaining
Correct Command to Step Down Primary Node

Which MongoDB shell command correctly forces the current primary node to step down and triggers an election?

Ars.forceStepDown(60)
Brs.stepdown(60)
Crs.step_down(60)
Drs.stepDown(60)
Attempts:
2 left
💡 Hint

Check the exact spelling and camel case of the command.

optimization
advanced
2:00remaining
Optimizing Read Preference for Secondary Nodes

You want to distribute read operations to secondary nodes to reduce load on the primary. Which read preference setting achieves this in MongoDB?

A"primaryOnly"
B"secondaryPreferred"
C"nearest"
D"primaryPreferred"
Attempts:
2 left
💡 Hint

Think about a setting that prefers secondaries but falls back to primary if needed.

🔧 Debug
expert
3:00remaining
Diagnosing Replica Set Election Issue

A MongoDB replica set has three nodes: one primary and two secondaries. Suddenly, the primary becomes unreachable. However, no new primary is elected. What is the most likely cause?

AThe majority of nodes are not available, so election cannot proceed.
BThe secondary nodes have higher priority than the primary.
CThe replica set configuration has no arbiter node.
DThe primary node was manually forced to step down without election enabled.
Attempts:
2 left
💡 Hint

Consider how MongoDB decides to elect a new primary based on node availability.