feat(debug): Adds a DEBUG STACKTRACE subcommand (#1848)

* feat(debug): Add a DEBUG STACKTRACE subcommand to print fibers state

* update helio
This commit is contained in:
Roy Jacobson 2023-09-13 12:51:35 +03:00 committed by GitHub
parent b91435e360
commit 62d32c353e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 2 deletions

2
helio

@ -1 +1 @@
Subproject commit 220c258a6754ea65e6dc06d77e0f22d7b07835ba
Subproject commit 5b4435851c7786ad014c0448cef319bc8b42752d

View file

@ -168,6 +168,7 @@ class Connection : public util::Connection {
}
void SetName(std::string name) {
util::ThisFiber::SetName(absl::StrCat("DflyConnection_", name));
name_ = std::move(name);
}

View file

@ -241,9 +241,11 @@ void DebugCmd::Run(CmdArgList args) {
" If <size> is specified then X character is concatenated multiple times to value:<num>",
" to meet value size.",
" If RAND is specified then value will be set to random hex string in specified size.",
" If SLOTS is specified then create keys only in given slots range."
" If SLOTS is specified then create keys only in given slots range.",
"OBJHIST",
" Prints histogram of object sizes.",
"STACKTRACE",
" Prints the stacktraces of all current fibers to the logs.",
"HELP",
" Prints this help.",
};
@ -283,6 +285,9 @@ void DebugCmd::Run(CmdArgList args) {
if (subcmd == "OBJHIST") {
return ObjHist();
}
if (subcmd == "STACKTRACE") {
return Stacktrace();
}
string reply = UnknownSubCmd(subcmd, "DEBUG");
return (*cntx_)->SendError(reply, kSyntaxErrType);
}
@ -724,4 +729,13 @@ void DebugCmd::ObjHist() {
(*cntx_)->SendBulkString(result);
}
void DebugCmd::Stacktrace() {
fb2::Mutex m;
shard_set->pool()->AwaitFiberOnAll([&m](unsigned index, ProactorBase* base) {
std::unique_lock lk(m);
fb2::detail::FiberInterface::PrintAllFiberStackTraces();
});
(*cntx_)->SendOk();
}
} // namespace dfly

View file

@ -39,6 +39,7 @@ class DebugCmd {
void Watched();
void TxAnalysis();
void ObjHist();
void Stacktrace();
ServerFamily& sf_;
ConnectionContext* cntx_;