Courseiva

CCNA Replication Questions

28 questions · Replication topic · All types, answers revealed

1
MCQmedium

What happens to the replica set if a majority of voting members are permanently lost?

A.The set automatically switches to a single-node mode to remain functional.
B.The set stops accepting writes to maintain consistency.
C.The secondary nodes elect a new primary regardless of the missing majority.
D.The primary node continues to accept writes for a short period.
AnswerB

Without a majority, the remaining nodes cannot achieve consensus for write operations. To prevent split-brain and maintain consistent data, the replica set stops accepting writes. This ensures that no data is committed until the cluster can confirm that a quorum of nodes has successfully processed the operation.

Why this answer

A replica set requires a majority of its voting members to be online to elect a new primary and perform write operations with majority concern. If the majority is lost, the remaining nodes enter a read-only state, as they cannot reach consensus. This is a critical failure scenario that requires immediate administrative intervention, such as reconfiguring the set or restoring the failed nodes.

Exam trap

Candidates incorrectly assume the replica set remains fully functional as long as one node is alive, ignoring the requirement for a majority to maintain cluster consistency.

2
MCQhard

When using 'readConcern: majority', what is the specific guarantee provided to the client?

A.It guarantees that the read will never return stale data.
B.It guarantees that the data read has been committed to a majority of nodes.
C.It forces the read to always come from the primary node.
D.It increases the speed of queries by ignoring consistency.
AnswerB

This read concern ensures that the returned data is part of the majority-committed history. This means the data is permanent and cannot be rolled back during a future election. It is a fundamental feature for building reliable distributed systems where data integrity must be maintained across node failures.

Why this answer

The 'majority' read concern guarantees that the data returned has been acknowledged by a majority of the replica set members. This ensures that the data is durable and will not be rolled back in the event of a primary failover. It provides a higher level of consistency for read operations, which is critical for applications that require strict data integrity and visibility.

Exam trap

Candidates frequently assume that 'readConcern: majority' guarantees data has been written to all nodes in the replica set rather than just a majority.

3
MCQhard

What occurs when a replica set member experiences a 'rollback'?

A.The node automatically merges its divergent data with the primary.
B.The node is permanently removed from the replica set until manually re-added.
C.The node discards data to align with the new primary and saves it to rollback files.
D.The node initiates a global election to force a return to its old state.
AnswerC

During a rollback, the node reverts its local state to the point of divergence from the current primary. The discarded operations are written to separate BSON files on the local filesystem. This process ensures the cluster returns to a consistent state while preserving the orphaned data for forensic analysis.

Why this answer

Rollback happens when a node was previously a primary, performed writes that were never replicated to the majority, and then rejoined the set after a new primary was elected. To maintain consistency, the old primary must discard those unacknowledged writes to match the new primary's state. These discarded writes are saved to a local BSON file for manual inspection and potential recovery by administrators.

Exam trap

Candidates frequently mistake rollback for a simple 'undo' operation or a database crash recovery, failing to realize it involves moving data to local files for manual administrator intervention.

4
MCQmedium

Which command is used to check the current replication lag status on a secondary node?

A.rs.status()
B.rs.printReplicationInfo()
C.rs.printSecondaryReplicationInfo()
D.db.stats()
AnswerC

This specific shell helper calculates the difference between the primary's last operation and the secondary's applied operation, outputting the lag in seconds. It is the most effective command for quickly identifying which nodes are falling behind and verifying that the entire set is effectively synchronized.

Why this answer

The rs.printSecondaryReplicationInfo() command provides a convenient summary of how far behind each secondary is compared to the primary. This is a vital tool for monitoring the health of the replica set and identifying nodes that may be having trouble keeping up with the write volume, which could signal underlying network or hardware performance bottlenecks.

Exam trap

Candidates often confuse this command with rs.status(), which provides general replica set health but requires manual calculation to determine the actual replication lag duration for secondaries.

5
Multi-Selecthard

Which THREE actions occur when a MongoDB secondary node performs an initial sync?

Select 3 answers
A.It copies all documents from each collection on the primary.
B.It immediately becomes the primary to speed up the process.
C.It applies oplog entries that occurred during the data cloning phase.
D.It builds all indexes defined in the collections.
E.It automatically purges all data from the primary node.
AnswersA, C, D

The first step of initial sync is to copy the data from all databases on the source. The node iterates through each collection and copies all documents. This is necessary to build a baseline state for the new member before it can begin processing the real-time oplog operations from the primary.

Why this answer

During initial sync, the node first clones all databases from the primary, then applies all changes recorded in the oplog that occurred during the cloning phase, and finally builds all necessary indexes for the collections. This multi-stage process ensures the new member reaches a consistent state with the primary without requiring an outage or downtime for the existing cluster members.

Exam trap

Test-takers often assume initial sync copies pre-built indexes directly from the primary, missing the fact that indexes must be built locally.

6
MCQmedium

You are a DBA for a MongoDB replica set. A secondary node has been down for several days and is far behind the primary. The oplog on the primary has wrapped, and the secondary's last oplog entry is no longer present. What must you do to bring the secondary back into sync?

A.Increase the oplog size on the primary to prevent wrapping and then restart the secondary.
B.Restart the secondary with the --resync option to force a full resync.
C.Run rs.syncFrom() on the secondary to point it to a different sync source.
D.Perform a full resync by stopping the secondary, deleting its data files, and restarting it.
AnswerD

When a secondary's oplog is too stale and the primary's oplog has wrapped, the secondary cannot catch up incrementally. The only way to resync is to perform a full resync, which involves stopping the secondary, deleting its data directory (or using rs.resync() in the shell), and restarting it to perform an initial sync from scratch.

Why this answer

If a secondary's last oplog entry is no longer in the primary's oplog, the secondary cannot catch up incrementally. A full resync is required, which means deleting the secondary's data files and restarting it to perform an initial sync. This process copies all data from the primary or another sync source.

Exam trap

The trap here is assuming that changing the sync source or increasing oplog size can recover a secondary whose oplog entries have been overwritten, rather than performing a full resync.

7
Multi-Selecthard

You are configuring a MongoDB replica set for a global application. You need to add a member that will never become primary and will be invisible to client applications. Which two steps must you take when adding this member? (Choose two.)

Select 2 answers
A.Set its votes to 0.
B.Set its slaveDelay to a large value.
C.Set its priority to 0.
D.Set its buildIndexes to false.
E.Set its hidden property to true.
AnswersC, E

Setting priority to 0 prevents the member from being elected primary. However, it alone does not make the member invisible to clients. A priority 0 member can still be a sync source and can serve reads if clients connect with appropriate read preferences, unless it is also hidden.

Why this answer

To create a member that never becomes primary and is invisible to clients, you must set both priority to 0 and hidden to true. Priority 0 ensures it cannot be elected primary, while hidden true prevents client visibility and use as a sync source. These two settings together meet the requirements.

Exam trap

The trap here is thinking that setting votes to 0 or slaveDelay is sufficient to make a member non-primary and hidden, when actually hidden and priority 0 are the required settings.

8
MCQeasy

In a replica set, what is the 'oplog' and why is it important?

A.A full backup of all data for disaster recovery.
B.A log of all read operations for performance auditing.
C.A capped collection that records all write operations for replication.
D.A temporary cache for incoming client write requests.
AnswerC

The oplog is indeed a capped collection that stores every modification to the data. Secondaries tail this collection continuously, pulling the operations and applying them to their own datasets. This ensures that all members of the replica set eventually reach the same state as the current primary node.

Why this answer

The oplog (operations log) is a capped collection that stores all write operations applied to the database. It is the fundamental mechanism for replication in MongoDB. Secondaries read from the primary's oplog and apply the same operations locally to stay in sync.

Without the oplog, there would be no way to propagate data changes reliably or recover from temporary periods of secondary node disconnection.

Exam trap

Candidates often confuse the oplog with the journal, believing the oplog is for crash recovery rather than the primary mechanism for asynchronous data replication between nodes.

9
MCQmedium

You are the DBA for a MongoDB 6.0 replica set with three voting members: rs0-primary (priority 2), rs0-secondary-1 (priority 1), and rs0-secondary-2 (priority 1). The primary fails and is unavailable for an extended period. You need to ensure that rs0-secondary-1 is elected as the new primary instead of rs0-secondary-2. Which action should you take before the primary fails?

A.Set rs0-secondary-1's hidden property to true and rs0-secondary-2's hidden property to false using rs.reconfig().
B.Set rs0-secondary-1's slaveDelay to 0 and rs0-secondary-2's slaveDelay to 3600 using rs.reconfig().
C.Set rs0-secondary-1's priority to 2 and rs0-secondary-2's priority to 0.5 using rs.reconfig().
D.Set rs0-secondary-1's votes to 1 and rs0-secondary-2's votes to 0 using rs.reconfig().
AnswerC

Raising rs0-secondary-1's priority above rs0-secondary-2's priority ensures that, when the current primary is unavailable, rs0-secondary-1 is more likely to win the election. Lowering rs0-secondary-2's priority to 0.5 further reduces its chance of being elected, while still allowing it to vote. This is the correct way to influence election outcomes without making the member unelectable.

Why this answer

Election priority determines which eligible secondary is most likely to win an election. By setting rs0-secondary-1's priority higher than rs0-secondary-2's, you make it the preferred candidate. Lowering rs0-secondary-2's priority to a non-zero value keeps it as a voting member but reduces its election chances.

This approach is the standard way to control primary election outcomes in a MongoDB replica set without making a member unelectable.

Exam trap

The trap here is confusing votes with priority; votes control whether a member can vote in elections, while priority controls which member is more likely to be elected primary.

10
MCQmedium

When adding a new member to an existing replica set, what is the most common reason for the initial sync process to fail if the data set is extremely large?

A.The primary node lacks sufficient RAM for the new member.
B.The oplog size on the primary is smaller than the duration of the sync.
C.The new member's hardware is not identical to the primary.
D.The replica set name does not match on the new member.
AnswerB

If the oplog is too small, the primary will roll over its log entries before the new member finishes copying all data. Once the primary wraps around, the new member loses the pointer to the operations it needs to replay, causing it to fall behind and fail the initial sync process.

Why this answer

Initial sync often fails for large data sets because the oplog on the primary node is too short. If the syncing node takes longer to copy the initial data than the time it takes for the primary to overwrite the necessary oplog entries, the syncing node will fall too far behind and be forced to restart the process, causing an infinite loop of sync failures.

Exam trap

Candidates often blame network latency or hardware issues. They overlook that the primary's oplog is a fixed size and will overwrite history if the sync takes too long.

11
MCQmedium

How can you prevent a specific node from becoming a primary in a replica set?

A.Set the node's 'votes' field to 0.
B.Set the node's 'priority' field to 0.
C.Set the node's 'hidden' field to true.
D.Remove the node from the replica set configuration.
AnswerB

A node with a priority of 0 is ineligible to become the primary. This configuration is the standard administrative method to pin a node to a secondary role. It is ideal for nodes that are undersized, geographically distant, or dedicated to tasks that should not be interrupted by election activity.

Why this answer

Setting the 'priority' value to 0 is the standard way to ensure a node never becomes primary. This is commonly done for nodes used for analytical tasks or as disaster recovery targets. It ensures these nodes act solely as passive secondaries, allowing them to serve read requests without ever interfering with the primary election process or causing unexpected failovers.

Exam trap

Candidates often confuse voting rights with eligibility to become primary, mistakenly believing that a priority 0 node cannot vote in elections.

12
MCQmedium

In a three-node replica set with default write concerns, what occurs when the primary node experiences a network partition and cannot communicate with the majority of the set?

A.The primary continues accepting writes until the partition is resolved.
B.The primary immediately crashes and shuts down the mongod process.
C.The primary steps down to secondary status, and the set elects a new primary.
D.The secondary nodes force a rollback on the primary node.
AnswerC

When a primary node detects that it can no longer see a majority of the voting members, it transitions to a secondary state. This is essential for cluster health because it allows the remaining nodes in the replica set to hold an election and select a new primary to handle operations.

Why this answer

When a primary loses connectivity to the majority of the replica set, it steps down to secondary status to prevent split-brain scenarios. This process ensures data consistency by requiring a majority of nodes to acknowledge writes. The remaining nodes will initiate an election to choose a new primary, maintaining the availability and integrity of the cluster during the temporary partition event.

Exam trap

Candidates often assume the partitioned primary continues accepting writes, forgetting that the lack of a network majority forces it to step down.

13
MCQmedium

What is the result of setting the 'votes' configuration to 0 for a specific node in a replica set?

A.The node will no longer replicate data from the primary.
B.The node will be removed from the replica set configuration.
C.The node will not participate in primary elections.
D.The node will automatically become the primary.
AnswerC

By setting votes to 0, the node is explicitly removed from the voting pool. This means the node will not contribute to the quorum required for electing a primary node. This is often used in large replica sets to ensure that voting remains efficient without requiring an excessive number of nodes.

Why this answer

Setting 'votes' to 0 makes the node a non-voting member. It will still replicate data and can serve read queries, but it will never participate in elections for a new primary. This is useful for scaling read capacity without increasing the quorum size, which would otherwise require adding more nodes to maintain a majority in the election process.

Exam trap

Candidates often mistakenly believe that a node with 'votes' set to 0 cannot perform any read operations or data replication, confusing it with a completely offline or disabled node.

14
MCQmedium

When a secondary node is lagging behind the primary, what is the most significant risk to the replica set if the lag time exceeds the length of the oplog?

A.The secondary will trigger an automatic election to become primary.
B.The secondary will enter a 'RECOVERING' state and require a full resync.
C.The primary will automatically reduce its write concern to accommodate the lag.
D.The replica set will automatically increase the oplog size to compensate.
AnswerB

When the oplog entries required for synchronization are no longer present on the primary, the secondary can no longer replicate incrementally. It transitions to a recovering state and must perform a full initial sync, which involves deleting existing data and copying the entire dataset from a healthy replica set member.

Why this answer

If a secondary falls behind the primary beyond the duration of the oplog, the secondary must perform an initial sync. This involves cloning the entire dataset, which is resource-intensive and can significantly degrade performance on the primary. Managing oplog size is a critical operational task to ensure that transient network issues do not force expensive full data copies across the network.

Exam trap

Candidates often guess that lagging nodes simply retry automatically or drop old data, missing the critical requirement for an expensive full resync.

15
MCQhard

Refer to the exhibit. If the primary node fails, which node is most likely to be elected the next primary based on optime?

A.Member[1] will always be elected.
B.Member[2] will likely be elected because it is more up-to-date.
C.No node can be elected because the timestamps are all different.
D.The election will trigger a full re-sync for all nodes.
AnswerB

During an election, nodes compare their oplog state. Member[2] has an optime of 95, making it the most current secondary. Nodes that are more up-to-date are preferred in elections because they minimize the need for rollbacks or data re-syncs, helping to maintain overall cluster consistency and reliability after a failure.

Why this answer

Elections prioritize the node with the most up-to-date data. The optime (operation time) represents the latest operation applied by the node. Member[2] is the most advanced secondary with a timestamp of 95, compared to Member[1] at 90.

Therefore, Member[2] has the highest probability of winning the election, ensuring the new primary has the most current data available in the set.

Exam trap

Candidates often pick the node with the highest priority setting, ignoring that optime takes precedence during primary elections.

16
MCQeasy

What is the primary function of the oplog in a MongoDB replica set?

A.To store user credentials and authentication data.
B.To record all operations for asynchronous replication.
C.To cache frequently accessed query results in memory.
D.To perform automatic backups for disaster recovery.
AnswerB

The oplog is essential for replication. It acts as a chronological ledger of every write operation performed on the primary. Secondaries continuously tail this log and apply the operations locally, ensuring that they stay synchronized with the primary node, which is the core mechanism behind MongoDB's high availability model.

Why this answer

The oplog, or operation log, is a capped collection that stores all write operations as they are applied to the database. Secondaries read these entries and apply them to their own datasets. This asynchronous replication process ensures that all members of the replica set eventually reach the same state, providing both data redundancy and high availability across the cluster.

Exam trap

Candidates often confuse the oplog with a backup or transaction log meant for point-in-time recovery. It is specifically designed for asynchronous replication between replica set members.

17
MCQmedium

What is the primary purpose of an Arbiter in a MongoDB replica set?

A.To serve as a standby node for automatic failover.
B.To participate in elections and help achieve a majority.
C.To provide read-only access to the database.
D.To replicate data from the primary to secondary nodes.
AnswerB

The arbiter exists strictly to vote in elections. In a replica set, elections require a majority of voting members to succeed. By adding an arbiter, you increase the number of voting members, which can help reach that majority quorum without the cost or storage requirements of a full-data node.

Why this answer

An arbiter's sole purpose is to participate in elections to help reach a majority vote without storing any data. By not storing data, it remains lightweight and requires minimal hardware resources, providing a cost-effective way to fulfill the voting requirements of a replica set in scenarios where an extra full-data node is not needed for capacity or redundancy.

Exam trap

Candidates often assume arbiters hold backup copies of data for failover scenarios, confusing them with standard secondary nodes.

18
MCQeasy

A three-member replica set has default settings, and all three members are healthy. A DBA needs to perform an index build on the primary during business hours. Which concern should the DBA consider regarding replica set behavior?

A.The index build will cause the primary to step down if any secondary has a replication lag greater than 10 seconds.
B.The index build will only be performed on the primary, and secondaries will build the index lazily during their next election.
C.The index build will be applied to all data-bearing members, and the primary waits for secondaries to finish before committing the index.
D.The index build will be rolled back on the secondaries if any secondary falls behind.
AnswerC

In MongoDB 4.4 and later, index builds are coordinated across all data-bearing replica set members. The primary starts the build and waits for the secondaries to complete their builds before committing the index, ensuring the index is consistent across the set. This behavior affects the duration and resource usage during the build.

Why this answer

In MongoDB 4.4 and later, index builds on replica sets are coordinated: the primary initiates the build, secondaries build concurrently, and the primary waits for all data-bearing secondaries to finish before committing. This ensures index consistency across the set. The operation can be resource-intensive and may impact replication lag temporarily, but it does not roll back or step down due to lag.

Exam trap

The trap here is assuming that index builds only happen on the primary and are later replicated through the oplog, when in fact modern MongoDB coordinates the build across all data-bearing members before committing.

19
MCQmedium

A DBA is adding a new secondary to an existing replica set. The data set is 2 TB, and the network bandwidth between the new member and the primary is 100 Mbps. The DBA wants to minimize the impact on the primary during the initial sync. Which approach should the DBA take?

A.Configure the new member as a hidden member to reduce its replication load.
B.Increase the oplog size on the primary to accommodate the initial sync.
C.Set the new member's priority to 0 during the initial sync to prevent it from becoming primary.
D.Seed the new member by copying the data files from an existing secondary while it is offline, then start it with the same replica set configuration.
AnswerD

Copying data files from an existing secondary (while it is offline) is a valid method to seed a new member. This avoids the primary having to serve the entire initial sync, distributing the load. It is faster than syncing over a slow network and reduces impact on the primary. The new member must be started with the same replica set name and oplog sufficient to catch up.

Why this answer

Seeding a new member by copying data files from an existing secondary (taken offline) is an efficient way to add a member without burdening the primary with a full initial sync over a slow network. This method leverages local copy speed and avoids consuming primary resources, which is critical when network bandwidth is limited.

Exam trap

The trap here is assuming that changing replica set settings like priority or hidden status will reduce the primary's load during initial sync, but those settings do not affect the data transfer itself.

20
MCQhard

A DBA is troubleshooting a replica set where the secondary is consistently lagging behind the primary by several hours. The DBA notices that the secondary's optime is far behind the primary's optime, and the secondary's oplog window is only 1 hour. The primary has a heavy write workload. Which action should the DBA take to reduce the replication lag and prevent the secondary from falling off the oplog?

A.Scale the secondary vertically by adding more CPU, RAM, or faster disk I/O.
B.Convert the secondary to an arbiter to reduce its workload.
C.Increase the write concern on the primary to ensure the secondary acknowledges writes.
D.Increase the size of the oplog on the primary and secondaries.
AnswerA

Replication lag often occurs when the secondary cannot apply oplog entries as fast as the primary generates them. Upgrading the secondary's hardware—especially faster disks and more CPU—can increase its oplog application rate, reducing lag. This addresses the underlying performance bottleneck and is the most direct way to improve replication throughput.

Why this answer

Replication lag is typically caused by the secondary's inability to apply oplog entries as quickly as the primary generates them. Improving the secondary's hardware resources—CPU, RAM, and especially disk I/O—increases its oplog application throughput, directly reducing lag. Increasing oplog size only buys time, and write concern does not affect replication speed.

Exam trap

The trap here is focusing on oplog size as the primary solution, when the immediate cause of lag is the secondary's insufficient resources to apply writes; a larger oplog only delays the inevitable resync if lag persists.

21
MCQmedium

You are the DBA for a three-member MongoDB replica set. The primary becomes unreachable due to a network partition, and two secondaries remain in communication. After the election timeout, one secondary is elected primary. What is the required condition for a new primary to be elected?

A.Any secondary with the highest priority automatically becomes primary without needing a majority.
B.The arbiter, if present, must vote and can be the sole voter to elect a primary.
C.The secondary with the most recent oplog entry is elected primary even if it is the only member available.
D.A majority of voting members must be available and able to communicate.
AnswerD

In MongoDB, a new primary is elected only if a majority of voting members are available and can communicate. In a three-member replica set, two voting members must be reachable. This ensures that the replica set does not split-brain and that the elected primary has the most recent data, as it must have the highest optime among the majority.

Why this answer

MongoDB replica sets require a majority of voting members to elect a primary. In a three-member set, two members must be available. The elected primary must have the highest optime among the majority to ensure data consistency.

This mechanism prevents split-brain scenarios and ensures that only one primary can accept writes at a time.

Exam trap

The trap here is assuming that the member with the highest priority or most recent oplog can become primary without a majority quorum.

22
MCQeasy

You are a DBA for a MongoDB replica set. A developer asks you to explain what the oplog is and why it is important. What is the correct description?

A.The oplog is a temporary file used during initial sync to transfer data from the primary to a new secondary.
B.The oplog is a cache that stores frequently accessed documents to improve read performance.
C.The oplog is a capped collection that records all write operations and is used by secondaries to replicate data from the primary.
D.The oplog is a log file on disk that records all queries and read operations for auditing purposes.
AnswerC

The oplog (operations log) is a capped collection in the local database that records all write operations. Secondaries continuously read the oplog from their sync source and apply the operations to their own data sets, ensuring replication. It is essential for maintaining data consistency across replica set members.

Why this answer

The oplog is a capped collection in the local database that records all write operations. Secondaries replicate by reading the oplog and applying the operations. This mechanism ensures that all members eventually have the same data, enabling high availability and failover.

Exam trap

The trap here is confusing the oplog with a general log file for auditing or a cache for read performance, when it is specifically a replication mechanism for write operations.

23
MCQeasy

A MongoDB DBA is investigating replication lag on a secondary member named rs0-2. The DBA runs rs.status() and notices that the 'optimeDate' of rs0-2 is several hours behind the primary's 'optimeDate'. The DBA wants to quickly determine the exact time difference. Which field in the rs.status() output should the DBA compare to calculate the replication lag?

A.The 'optimeDate' field of each member.
B.The 'pingMs' field of each member.
C.The 'lastHeartbeat' field of each member.
D.The 'optime' field of each member.
AnswerA

The 'optimeDate' field in rs.status() provides the human-readable date of the last oplog entry applied by each member. Subtracting the secondary's 'optimeDate' from the primary's 'optimeDate' gives the replication lag. This is the standard method to quickly assess lag.

Why this answer

Replication lag is calculated by comparing the 'optimeDate' of the secondary with that of the primary. The 'optimeDate' field shows the timestamp of the last oplog entry applied by each member, so the difference indicates how far behind the secondary is.

Exam trap

The trap here is confusing network latency metrics like 'pingMs' or heartbeat information with actual replication lag, which is based on oplog application timestamps.

24
MCQmedium

In a three-node replica set with default write concern w:1, what happens to an unacknowledged write if the primary crashes immediately after receiving the write command but before replicating it to secondaries?

A.The write is automatically rolled back and re-applied when the old primary recovers.
B.The write remains in the local storage of the crashed node and becomes visible upon restart.
C.The write is lost, and the new primary will not contain the data.
D.The replica set triggers an automatic consistency recovery to force the write to other nodes.
AnswerC

Since the write was only acknowledged by the original primary and not replicated to the secondaries, it exists only on the crashed node. When a new primary is elected, it only contains data that was replicated. The original write is effectively discarded from the cluster's consistent view.

Why this answer

With w:1, the primary acknowledges the write as soon as it is applied to its local oplog. If the primary fails before replication, the new primary elected from the remaining nodes will not contain this write. This demonstrates the critical trade-off between performance and durability.

Clients must use w:'majority' to ensure data consistency during failover events, as single-node acknowledgments are insufficient to guarantee persistence against primary loss.

Exam trap

Candidates mistakenly assume that because the primary acknowledged the write, the data is safe, forgetting that a single-node acknowledgment does not guarantee survival during a failover.

25
Multi-Selecthard

You are administering a MongoDB 6.0 replica set with three members: a primary and two secondaries. You need to perform a rolling maintenance on the secondaries, which involves restarting each secondary one at a time. Which two actions must you take to ensure that the replica set remains available for writes during the maintenance? (Choose two.)

Select 2 answers
A.Disable authentication on the replica set to simplify the restart process.
B.Set the priority of the primary to 0 to prevent it from being re-elected during the maintenance.
C.Restart the secondaries one at a time, waiting for each to fully rejoin and catch up before proceeding to the next.
D.Use rs.stepDown() to force the primary to step down before restarting any secondary.
E.Ensure that the primary remains up and can communicate with a majority of voting members.
AnswersC, E

Restarting secondaries one at a time ensures that at any moment, at least one secondary remains available to maintain a majority with the primary. Waiting for each secondary to fully rejoin and catch up before restarting the next prevents the set from losing majority and ensures that if the primary fails, a fully caught-up secondary can be elected. This is a standard rolling maintenance practice.

Why this answer

To keep a replica set writable during rolling maintenance on secondaries, you must ensure the primary retains a majority of voting members. In a three-member set, this means keeping the primary and at least one secondary online. Restarting secondaries one at a time and waiting for each to catch up before moving to the next maintains majority and data consistency.

This approach allows the primary to continue accepting writes without interruption, provided no other failures occur.

Exam trap

The trap here is thinking that you need to step down the primary or change priorities to perform maintenance; in reality, you only need to maintain majority by keeping the primary and at least one secondary available.

26
MCQeasy

Which member type in a MongoDB replica set is best suited for a geographically distant data center to provide read-only access without influencing elections?

A.Arbiter
B.Hidden Member
C.Priority 0 Secondary
D.Delayed Secondary
AnswerC

A priority 0 secondary cannot be elected primary, making it perfect for remote sites. It maintains a full copy of the data, which allows it to serve read requests locally. Because it cannot become primary, it eliminates the risk of a high-latency node taking control of the entire cluster's operations.

Why this answer

A priority 0 secondary is ideal for this scenario. By setting the priority to zero, the node is ineligible to become primary, preventing it from participating in elections. This is critical for nodes in remote locations where high latency could disrupt election timing or cause unnecessary re-elections, while still providing low-latency read access to users in that specific geographical region.

Exam trap

Candidates often suggest deploying an arbiter for remote read-only data centers, forgetting that arbiters do not store any data.

27
MCQeasy

Refer to the exhibit. What is the primary function of the node with _id 2 in this replica set?

A.It stores a copy of the data and can serve read queries.
B.It performs automatic failover by hosting a redundant copy of the oplog.
C.It provides a vote during elections to help maintain a majority.
D.It acts as a load balancer for incoming read requests.
AnswerC

The arbiter is specifically configured to provide a voting member to the replica set without requiring the storage overhead of a data-bearing node. By participating in elections, it helps reach a majority of votes, which is required to elect a new primary during failover events in small sets.

Why this answer

An arbiter exists solely to participate in elections and break ties. It does not replicate data or serve read requests, making it a low-resource way to achieve a majority vote in a set. This is crucial for environments where a full-data secondary is cost-prohibitive but high availability is still required to maintain quorum during network partitions.

Exam trap

Candidates often confuse arbiters with secondary nodes, incorrectly assuming that an arbiter replicates data or can be promoted to a primary node during a failover event, which is fundamentally false.

28
Multi-Selecthard

Which THREE factors can significantly impact the time taken for a new primary election?

Select 3 answers
A.The network latency between replica set members.
B.The total number of documents in the largest collection.
C.The heartbeat timeout setting (electionTimeoutMillis).
D.The amount of free RAM available on the primary node.
E.The total number of voting members in the replica set.
AnswersA, C, E

Higher network latency increases the time required for heartbeat signals to travel between nodes. If heartbeats take longer to arrive, the remaining nodes will wait longer before declaring the primary unreachable, thereby increasing the total time elapsed before a new election is triggered and a new primary is established.

Why this answer

The speed of a failover is determined by how quickly nodes detect the primary is down and how quickly they can reach a consensus. Network latency between nodes, the heartbeat interval, and the number of nodes in the set are all critical. Optimizing these factors is necessary for maintaining a high-availability architecture that can recover from outages within the expected time window defined by SLAs.

Exam trap

Candidates often overlook network latency and heartbeat timeouts, incorrectly assuming replica set elections are instantaneous or solely dependent on hardware specs.

Ready to test yourself?

Try a timed practice session using only Replication questions.