0

I'm preparing for the MongoDB developer certification and a practice question has me stumped:

Which of the following is true of the mechanics of replication in MongoDB? Check all that apply.

a. Operations on the primary are recorded in a capped collection called the oplog.

b. Members of a replica set may replicate data from any other data-bearing member of the set by default.

c. Clients read from the nearest member of a replica set by default.

I selected just a., but b. is considered true as well.

My understanding is that secondary nodes in a replica set will only poll the primary node's oplog and will only switch to another secondary if the primary goes down and that other secondary becomes the new primary node.

The wording in b. any other data-bearing member of the set by default implies secondaries can poll each other even if the primary node is still active. I assume this isn't the case. Is my understanding correct?

craigcaulfield
  • 3,381
  • 10
  • 32
  • 40
  • 1
    This question really belongs on [dba.stackexchange.com](https://dba.stackexchange.com) which is the site to use for database administration and configuration questions. StackOverflow is for programming topics only, of which this question is not. **Please move your question to the correct site by deleting and reposting.** – Neil Lunn Nov 09 '19 at 09:22

1 Answers1

2

b. Members of a replica set may replicate data from any other data-bearing member of the set by default.

This means that some members in the replica-set are eligible to replicate data from another data-bearing member. This another data bearing member will be a primary. Note that the data gets written only to a primary (which is replicated to other members which are eligible).

Some nodes may not be eligible to replicate data - for example, an arbiter (an arbiter does not have a copy of data set and cannot become a primary and it participates in elections to vote).

By default, means that this operation of replication is automatic.

Notes the documentation:

  • A secondary maintains a copy of the primary’s data set. To replicate data, a secondary applies operations from the primary’s oplog to its own data set in an asynchronous process.
  • A secondary can become a primary, if the current primary becomes unavailable; the secondaries hold an election and elect a new primary.
  • Clients can read data from secondary members (and this can be specified in Read Preference).
prasad_
  • 12,755
  • 2
  • 24
  • 36
  • It may be that `b.` is not well worded, but *from any other data-bearing member* seems to imply replication from both primary and secondary nodes. I'll assume replication is only possible from primary nodes. – craigcaulfield Nov 09 '19 at 09:14
  • I guess we have to know that data gets written to only a _primary_ (it is implicit). Hence, this _any other member_ can be primary only. I think knowing that is also part of the test. – prasad_ Nov 09 '19 at 09:17
  • In case you think the wording of the question / options is not clear to you, you can write (to MongoDB University, I think) about the issue and get it corrected or clarified. I think there is a link after each question in the practice tests where you can comment or say if there is an issue. – prasad_ Nov 09 '19 at 09:26
  • Very well, but the question itself has nothing to do with **Programming**, which is the purpose of this site. In future just flag the obvious "not programming question" for removal to another site and move on. If you want to answer these types of questions, then please do so on the correct site. This is the wrong place. – Neil Lunn Nov 09 '19 at 09:26
  • Yes, the question could have been posted in another way, rather than pointing to the Exam, and the words, etc. But, then exams can make one little nervous and post such queries. – prasad_ Nov 09 '19 at 09:30
  • 2
    @craigcaulfield Secondaries can replicate from other secondaries with newer oplogs by default: this is called [chained replication](https://docs.mongodb.com/manual/tutorial/manage-chained-replication/). This feature is useful for distributed deployments so remote secondaries can sync with a member of the replica set that is nearer (according to network latency) than the current primary. – Stennie Nov 10 '19 at 21:09