mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Make worker restart in cluster btest race-proof
This commit is contained in:
parent
3734adef2d
commit
08daef8d42
1 changed files with 14 additions and 8 deletions
|
@ -20,25 +20,28 @@ redef exit_only_after_terminate=T;
|
||||||
redef Log::default_rotation_interval = 0secs;
|
redef Log::default_rotation_interval = 0secs;
|
||||||
|
|
||||||
global topic = "test-topic";
|
global topic = "test-topic";
|
||||||
|
global restart_worker1_signal: event();
|
||||||
|
|
||||||
@if ( Supervisor::is_supervisor() )
|
@if ( Supervisor::is_supervisor() )
|
||||||
|
|
||||||
global supervisor_output_file: file;
|
global supervisor_output_file: file;
|
||||||
global worker1_starts = 0;
|
global worker1_restart_signals = 0;
|
||||||
|
|
||||||
event Cluster::Experimental::node_fully_connected(name: string, id: string, resending: bool)
|
event restart_worker1_signal()
|
||||||
{
|
{
|
||||||
if ( name != "worker-1" )
|
# Wait for the signal to be raised twice, which means worker-1 is fully connected and
|
||||||
|
# the cluster is started.
|
||||||
|
if ( ++worker1_restart_signals < 2 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
# Restart worker-1 twice
|
# Shut down once we restarted worker-1 twice.
|
||||||
if ( ++worker1_starts >= 3 )
|
if ( worker1_restart_signals > 3 )
|
||||||
{
|
{
|
||||||
terminate();
|
terminate();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
print supervisor_output_file, fmt("restarting %s", name);
|
print supervisor_output_file, "restarting worker-1";
|
||||||
Supervisor::restart("worker-1");
|
Supervisor::restart("worker-1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,13 +94,16 @@ event Cluster::Experimental::node_fully_connected(name: string, id: string, rese
|
||||||
{
|
{
|
||||||
print "node fully connected";
|
print "node fully connected";
|
||||||
|
|
||||||
if ( Cluster::node == "manager" )
|
if ( Cluster::node == "manager" && name == "worker-1" )
|
||||||
Broker::publish(topic, Cluster::Experimental::node_fully_connected, name, id, resending);
|
Broker::publish(topic, restart_worker1_signal);
|
||||||
}
|
}
|
||||||
|
|
||||||
event Cluster::Experimental::cluster_started()
|
event Cluster::Experimental::cluster_started()
|
||||||
{
|
{
|
||||||
print "cluster_started";
|
print "cluster_started";
|
||||||
|
|
||||||
|
if ( Cluster::node == "manager" )
|
||||||
|
Broker::publish(topic, restart_worker1_signal);
|
||||||
}
|
}
|
||||||
|
|
||||||
event zeek_done()
|
event zeek_done()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue