Refactoring slave_running check to execute its own db query