开发者

Does adding a redis slave issue a blocking call to the master?

开发者 https://www.devze.com 2023-02-07 13:54 出处:网络
It is unclear to me from the documentation on replication whether the SYNC command is blocking. It seems like it shouldn\'t be (after all, spinning up a new slave would stop the master from serving r

It is unclear to me from the documentation on replication whether the SYNC command is blocking.

It seems like it shouldn't be (after all, spinning up a new slave would stop the master from serving requests), but I'd like confirmation of that.

For context, I'm looking at adding a slave to a master hosting about 8GB of data with no disk sync*.

*Historically, data loss has not been a concern. We're changing that, so replication and persistence are bein开发者_如何转开发g "back ported" to a degree.


the master will just perform a BGSAVE on SYNC request from the slave, so it's not a blocking operation.

So the sequence is:

  • slave asks for SYNC
  • master BGSAVE, slave waits
  • master BGSAVE finished, the initial bulk data (the .rdb file) is transfered to slave
  • master accumulates all the new differences for the slave
  • master finishes sending the whole initial rdb file to slave
  • master start feeding the slave with the accumulated buffer, and with anything new arriving from clients, if they are writes.

It also works if the master is not configured to save, simply it will produce an .rdb just for master <-> slave synchronization. In master instances configured without "save" lines in redis.conf BGSAVE is not called automatically, but can still be called by the user if there is the need to save an .rdb file.

0

精彩评论

暂无评论...
验证码 换一张
取 消