Giter Site home page Giter Site logo

Comments (1)

gqtc avatar gqtc commented on August 16, 2024

根据注释以及自己的理解,这两条语句的作用是:因为新创建的积压队列为空,因此不能为从节点提供部分重同步功能。

正常的同步过程中,主节点上的server.master_repl_offset和从节点的server.master->reploff是保持一致的,当有新的客户端命令发送给主节点时,server.master_repl_offset会增加命令的长度值,然后主节点将该命令发送给从节点时,从节点的server.master->reploff也增加相应的字节数,从而达到主节点server.master_repl_offset和从节点server.master->reploff的再度一致;

当主从节点之间的连接断掉时,从节点server.master->reploff保持不变,当主节点与所有的从节点断链之后,可能会释放积压队列。

当有之前的从节点重新连接该主节点时,主节点创建积压队列,从节点发来的offset为erver.master->reploff+1,而主节点创建积压队列时,执行下面两条语句:

server.master_repl_offset++;
server.repl_backlog_off = server.master_repl_offset+1;

这样从节点发来的offset一定是小于主节点的server.repl_backlog_off的,因此,主节点就不会为该从节点执行部分重同步功能。

个人理解,欢迎讨论!

from redis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.