0

Is it possible in a three-member-replica set (1 primary, 2 secondaries) to update records on the primary, or even delete several records and insert the updated data, and still execute read-ops on the secondaries by setting the read-preference to secondary?

I do know that all write-ops will only go to the primary and will be replicated by the secondaries but I do not know if it is possible to delay the replication or even better to replicate one secondary and after it is finished to replicate the other one.

Thank in advance

0

Actually, it is pretty easy to configure a delayed member of a replica set via the shell:

cfg = rs.conf()
cfg.members[0].priority = 0
cfg.members[0].hidden = true
cfg.members[0].slaveDelay = 3600
rs.reconfig(cfg)

In this example taken from the docs, the first member of replica set will be reconfigured to have a delay of one hour. Note that this delayed member can never become primary (and should not). By setting the hidden attribute to false, you may end up reading from this member by setting the read preference to secondary, but there is no guarantee for it. So you have to connect directly to the delayed member (remember to set the slaveOk option), which obviously lacks failover capacity.

Waiting for the data to be acknowledged by one secondary and then send it to the next would be very inefficient, and therefor I doubt that it is possible. Think of how long it would take when you had a replication factor of 15, multiple data centers involved and a write concern of majority...

2
  • Okay nice. Thanks for your answer and your concerns about my intentions.
    – aQuip
    Jul 7 '14 at 14:29
  • Actually, you don't need to set hidden to true when connecting directly to the delayed member. Jul 7 '14 at 15:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.