Update log cursor timeout check

This commit is contained in:
Zhe Wu 2023-03-21 22:03:17 -07:00
parent 00055bd76b
commit b4e62b9b3e
3 changed files with 7 additions and 3 deletions

View File

@ -325,6 +325,7 @@ public:
double lastConnectionFailure;
double connectionFailuresDisableDuration;
bool speedUpSimulation;
double connectionFailureEnableTime; // Last time connection failure is enabled.
BackupAgentType backupAgents;
BackupAgentType drAgents;
bool restarted = false;

View File

@ -73,8 +73,8 @@ ISimulator::ISimulator()
: desiredCoordinators(1), physicalDatacenters(1), processesPerMachine(0), listenersPerProcess(1), usableRegions(1),
allowLogSetKills(true), tssMode(TSSMode::Disabled), configDBType(ConfigDBType::DISABLED), isStopped(false),
lastConnectionFailure(0), connectionFailuresDisableDuration(0), speedUpSimulation(false),
backupAgents(BackupAgentType::WaitForType), drAgents(BackupAgentType::WaitForType), allSwapsDisabled(false),
blobGranulesEnabled(false) {}
connectionFailureEnableTime(0), backupAgents(BackupAgentType::WaitForType), drAgents(BackupAgentType::WaitForType),
allSwapsDisabled(false), blobGranulesEnabled(false) {}
ISimulator::~ISimulator() = default;
bool simulator_should_inject_fault(const char* context, const char* file, int line, int error_code) {
@ -2785,6 +2785,7 @@ void enableConnectionFailures(std::string const& context) {
if (g_network->isSimulated()) {
g_simulator->connectionFailuresDisableDuration = 0;
g_simulator->speedUpSimulation = false;
g_simulator->connectionFailureEnableTime = now();
TraceEvent(SevWarnAlways, ("EnableConnectionFailures_" + context).c_str());
}
}

View File

@ -343,7 +343,9 @@ ACTOR Future<Void> serverPeekParallelGetMore(ILogSystem::ServerPeekCursor* self,
// A cursor for a log router can be delayed indefinitely during a network partition, so only fail
// simulation tests sufficiently far after we finish simulating network partitions.
CODE_PROBE(e.code() == error_code_timed_out, "peek cursor timed out");
if (now() >= FLOW_KNOBS->SIM_SPEEDUP_AFTER_SECONDS + SERVER_KNOBS->PEEK_TRACKER_EXPIRATION_TIME) {
if (g_network->isSimulated() && now() >= g_simulator->connectionFailureEnableTime +
FLOW_KNOBS->SIM_SPEEDUP_AFTER_SECONDS +
SERVER_KNOBS->PEEK_TRACKER_EXPIRATION_TIME) {
ASSERT_WE_THINK(e.code() == error_code_operation_obsolete ||
SERVER_KNOBS->PEEK_TRACKER_EXPIRATION_TIME < 10);
}