Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix isOnMainThread in Sim2 #11954

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions fdbrpc/include/fdbrpc/simulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ class ISimulator : public INetwork {
WipedString makeToken(int64_t tenantId, uint64_t ttlSecondsFromNow);

static thread_local ProcessInfo* currentProcess;
static thread_local bool isMainThread;

bool checkInjectedCorruption();

Expand Down
4 changes: 3 additions & 1 deletion fdbrpc/sim2.actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@

ISimulator* g_simulator = nullptr;
thread_local ISimulator::ProcessInfo* ISimulator::currentProcess = nullptr;
thread_local bool ISimulator::isMainThread = false;

ISimulator::ISimulator()
: desiredCoordinators(1), physicalDatacenters(1), processesPerMachine(0), listenersPerProcess(1), usableRegions(1),
Expand Down Expand Up @@ -1401,6 +1402,7 @@ class Sim2 final : public ISimulator, public INetworkConnections {

static void runLoop(Sim2* self) {
ISimulator::ProcessInfo* callingMachine = self->currentProcess;
ISimulator::isMainThread = true;
int lastPrintTime = 0;
while (!self->isStopped) {
if (self->taskQueue.canSleep()) {
Expand Down Expand Up @@ -2666,7 +2668,7 @@ class Sim2 final : public ISimulator, public INetworkConnections {
PromiseTask* p = new PromiseTask(getCurrentProcess(), std::move(signal));
taskQueue.addReadyThreadSafe(isOnMainThread(), taskID, p);
}
bool isOnMainThread() const override { return net2->isOnMainThread(); }
bool isOnMainThread() const override { return ISimulator::isMainThread; }
Future<Void> onProcess(ISimulator::ProcessInfo* process, TaskPriority taskID) override {
return delay(0, taskID, process);
}
Expand Down
3 changes: 2 additions & 1 deletion tests/rare/AllSimUnitTests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ startDelay = 0
[[test.workload]]
testName = 'UnitTests'
#maxTestCases = 1
testsMatching = '/'
testsMatching = '/'
testsIgnored = '/fdbrpc/grpc'
1 change: 1 addition & 0 deletions tests/rare/SpecificUnitTests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ runSetup=false
testName = 'UnitTests'
maxTestCases = 1
testsMatching = '/'
testsIgnored='/fdbrpc/grpc'