4.1.2. Event ConfirmationsWhen an event is processed by the slon process for a remote node, a CONFIRM message is generated byinserting 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.
For instance, many people have run afoul of problems with SLONIK SUBSCRIBE SET, when subscribing a newset.Be aware (and beware!) that a SLONIK SUBSCRIBE SET request will return the event confirmation almostimmediately, 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 SYNCevent...SYNC...Generates a SYNC event on a specified node.ID = ivalThe 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);
都是一样的效果