Skip to content

Commit

Permalink
chore: Add vlog printings every time we switch global state
Browse files Browse the repository at this point in the history
Should help debugging #1204

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
  • Loading branch information
romange committed May 13, 2023
1 parent 39aed00 commit da66844
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
19 changes: 19 additions & 0 deletions src/server/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -320,3 +320,22 @@ GenericError Context::ReportErrorInternal(GenericError&& err) {
}

} // namespace dfly

namespace std {

ostream& operator<<(ostream& os, const dfly::GlobalState gs) {
switch (gs) {
case dfly::GlobalState::ACTIVE:
return os << "ACTIVE";
case dfly::GlobalState::LOADING:
return os << "LOADING";
case dfly::GlobalState::SAVING:
return os << "SAVING";
case dfly::GlobalState::SHUTTING_DOWN:
return os << "SHUTTING DOWN";
}

return os;
}

} // namespace std
6 changes: 6 additions & 0 deletions src/server/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,3 +343,9 @@ inline uint32_t MemberTimeSeconds(uint64_t now_ms) {
}

} // namespace dfly

namespace std {

ostream& operator<<(ostream& os, const dfly::GlobalState gs);

} // namespace std
3 changes: 3 additions & 0 deletions src/server/main_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1739,6 +1739,9 @@ GlobalState Service::SwitchState(GlobalState from, GlobalState to) {
lock_guard lk(mu_);
if (global_state_ != from)
return global_state_;

VLOG(1) << "Switching state from " << global_state_ << " to " << to;

global_state_ = to;

pp_.Await([&](ProactorBase*) { ServerState::tlocal()->set_gstate(to); });
Expand Down
10 changes: 0 additions & 10 deletions src/server/server_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -563,16 +563,6 @@ Future<std::error_code> ServerFamily::Load(const std::string& load_path) {
return {};
}

#if 0
auto& pool = service_.proactor_pool();
// Deliberately run on all I/O threads to update the state for non-shard threads as well.
pool.Await([&](ProactorBase*) {
// TODO: There can be a bug where status is different.
CHECK(ServerState::tlocal()->gstate() == GlobalState::IDLE);
ServerState::tlocal()->set_gstate(GlobalState::LOADING);
});
#endif

auto& pool = service_.proactor_pool();

vector<Fiber> load_fibers;
Expand Down

0 comments on commit da66844

Please sign in to comment.