对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);

都是一样的效果







本文转自健哥的数据花园博客园博客,原文链接:http://www.cnblogs.com/gaojian/p/3227210.html,如需转载请自行联系原作者


目录
相关文章
|
1月前
|
Java
理解wait()、notify()和notifyAll()
【10月更文挑战第9天】
|
6月前
|
弹性计算 运维 Shell
wait命令
【4月更文挑战第29天】
47 2
|
6月前
|
API
wait-nofity
wait-nofity
41 0
|
存储 缓存 安全
sleep () 和 wait () 的区别
sleep () 和 wait () 的区别
86 0
|
Java 程序员
sleep 和 wait 的区别
Java 中,线程的 "sleep" 和 "wait" 方法区别
129 0
|
监控
实践解读CLOSE_WAIT和TIME_WAIT
实践解读CLOSE_WAIT和TIME_WAIT
389 0
实践解读CLOSE_WAIT和TIME_WAIT
线程 - wait & sleep 区别
线程 - wait & sleep 区别
119 0
|
Java
sleep与wait区别
第一个区别是在对系统资源的占用上。 wait是Object类的一个函数(也就意味着所有对象都有这个函数),指线程处于进入等待状态,此时线程不占用任何资源,不增加时间限制。wait可以被notify和notifyAll函数唤醒(当然这两个同时也是Object的函数)。 而sleep则是Thread类的一个函数,指线程被调用时,占着CPU不工作。此时,系统的CPU部分资源被占用,其他线程无法进入,会增加时间限制。
141 0