zoukankan      html  css  js  c++  java
  • 对Slony-I中wait on的理解

    http://slony.info/documentation/2.1/advanced.html#AEN1425

    4.1.2. Event Confirmations
    
    When an event is processed by the slon process for a remote node, a CONFIRM message is generated by
    
    inserting a tuple into the sl_confirm table.
    
    This tuple indicates that a particular event has been confirmed by a particular receiver node.
    
    Confirmation messages are then transferred back to all other nodes in the cluster.

    http://slony.info/documentation/2.1/stmtwaitevent.html

    http://slony.info/documentation/2.1/stmtsync.html

    For instance, many people have run afoul of problems with SLONIK SUBSCRIBE SET, when subscribing a new
    set.
    
    Be aware (and beware!) that a SLONIK SUBSCRIBE SET request will return the event confirmation almost
    
    immediately, even though there might be several hours of work to do before the subscription is ready.
    
    The trouble with SLONIK SUBSCRIBE SET is that it is processed as two events, one on the origin node,
    
    with a second event, to enable the subscription, on the subscriber. 
    
    In order to more reliably monitor from within a slonik script that SLONIK SUBSCRIBE SET is complete,
    
    you may submit a SLONIK SYNC event after the subscription, and have the WAIT request wait on the SYNC
    
    event
    
    ...
    
    SYNC
    
    ...
    
    Generates a SYNC event on a specified node.
    
    ID = ival
    
    The node on which to generate the SYNC event.
    
    Example
    
          SYNC (ID = 1);
    
          WAIT FOR EVENT (ORIGIN = 1, CONFIRMED = 2, WAIT ON=1); ...
    
     Slonik does not wait for event confirmations before performing this command.

    根据以上的说明,

    为了保证复数个Slonik命令的执行顺序关系,
    通过SYNC和 WAIT FOR EVENT 命令来控制 
    SUBSCRIBE SET 命令执行一直到完毕,才开始其它命令的执行。

    我个人的理解是,SUBSCRIBE SET 命令实际执行完毕的时候,
    无论Provider也好,还是Receiver也罢,其所拥有的sl_confirm表的内容,
    都可以起到表示 SUBSCRIBE SET 命令实际执行完毕的作用。

    所以只要 sync 与 wait for event 的 wait on 中的 id 相同,都是可以的。

    SUBSCRIBE SET (ID = 999, PROVIDER = 1, RECEIVER = 2);
    SYNC (ID = 1)
    WAIT FOR EVENT (ORIGIN = 1, CONFIRMED = ALL, WAIT ON=1);

    SUBSCRIBE SET (ID = 999, PROVIDER = 1, RECEIVER = 2);
    SYNC (ID = 2)
    WAIT FOR EVENT (ORIGIN = 1, CONFIRMED = ALL, WAIT ON=2);

    都是一样的效果

  • 相关阅读:
    JS--XML 操作
    JS--中的 Cookie 与存储
    php qr生成二维码
    jQuery cookie插件保存用户登陆信息
    linux BASH shell设置字体与背景颜色
    linux iostat命令详解 磁盘操作监控工具
    Nginx下10个安全问题提示
    PHP计算某个目录大小的方法
    php验证是否是md5编码的代码
    JS正则表达式获取字符串中特定字符
  • 原文地址:https://www.cnblogs.com/gaojian/p/3227210.html
Copyright © 2011-2022 走看看