Why there is a mutex in sim2_actor

Hi, I was looking into code of fdb’s simulation related stuff, and I saw that Sim2 actually uses mutex. My understanding is that the whole system is running inside a thread when in simulation model; so why there is a need to use mutex? For example, in sim2_actor.cpp

tasks.push(Task(time + seconds, taskID, taskCount++, machine, f));

That’s a good question. I tried to run a simulation using lldb and added breakpoints in the runLoop(). From what I can tell, there is indeed only one thread running.

@Evan, do you know the reason of using mutex here?

There’s things that need to be able to queue up work into flow. When sim2 is used from an fdb client, then I’d think most operations would work this way? However, I still think fdbserver will occasionally activate work from other threads (e.g. when libeio completes a future?)

Apparently I wrote this a long time ago while adding some sort of support for running threads in simulation. It looks like there are a couple unit tests in the multi-version client that might make use of this, and there’s a workload that uses it as well that I don’t think we actually run in simulation.