Progress the simulator clock even when there are messages to deliver
This commit is contained in:
parent
f6017697d6
commit
923325b8fa
@ -75,6 +75,8 @@ bool SimulatorHandle::MaybeTickSimulator() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We allow the simulator to progress the state of the system only
|
||||
// after all servers are blocked on receive.
|
||||
spdlog::info("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ simulator tick ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
|
||||
stats_.simulator_ticks++;
|
||||
|
||||
@ -88,11 +90,6 @@ bool SimulatorHandle::MaybeTickSimulator() {
|
||||
cv_.notify_all();
|
||||
}
|
||||
|
||||
if (in_flight_.empty()) {
|
||||
// return early here because there are no messages to schedule
|
||||
|
||||
// We tick the clock forward when all servers are blocked but
|
||||
// there are no in-flight messages to schedule delivery of.
|
||||
const Duration clock_advance = std::chrono::microseconds{time_distrib_(rng_)};
|
||||
cluster_wide_time_microseconds_ += clock_advance;
|
||||
|
||||
@ -113,12 +110,11 @@ bool SimulatorHandle::MaybeTickSimulator() {
|
||||
throw utils::BasicException{"Cluster has executed beyond its configured abort_time"};
|
||||
}
|
||||
|
||||
// if the clock is advanced, no messages should be delivered also.
|
||||
// do that in a future tick.
|
||||
if (in_flight_.empty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (config_.scramble_messages) {
|
||||
if (config_.scramble_messages && in_flight_.size() > 1) {
|
||||
// scramble messages
|
||||
std::uniform_int_distribution<size_t> swap_distrib(0, in_flight_.size() - 1);
|
||||
const size_t swap_index = swap_distrib(rng_);
|
||||
|
@ -52,7 +52,7 @@ class SimulatorHandle {
|
||||
std::set<Address> blocked_on_receive_;
|
||||
std::set<Address> server_addresses_;
|
||||
std::mt19937 rng_;
|
||||
std::uniform_int_distribution<int> time_distrib_{5, 50};
|
||||
std::uniform_int_distribution<int> time_distrib_{0, 50};
|
||||
std::uniform_int_distribution<int> drop_distrib_{0, 99};
|
||||
SimulatorConfig config_;
|
||||
MessageHistogramCollector histograms_;
|
||||
|
Loading…
Reference in New Issue
Block a user