Skip to content

Commit

Permalink
print tid of the stalling thread.
Browse files Browse the repository at this point in the history
Reviewed By: yfeldblum

Differential Revision: D30914679

fbshipit-source-id: 79a609ed1eda97a97e6eeeb47038a1e746b75e2d
  • Loading branch information
mshneer authored and facebook-github-bot committed Sep 14, 2021
1 parent a082c77 commit 61e00b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion folly/executors/IOThreadPoolDeadlockDetectorObserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <memory>
#include <folly/concurrency/DeadlockDetector.h>
#include <folly/executors/IOThreadPoolDeadlockDetectorObserver.h>
#include <folly/system/ThreadId.h>

namespace folly {

Expand All @@ -33,8 +34,10 @@ void IOThreadPoolDeadlockDetectorObserver::threadStarted(
auto eventBase = folly::IOThreadPoolExecutor::getEventBase(h);
// This Observer only works with IOThreadPoolExecutor class.
CHECK_NOTNULL(eventBase);
auto thid = folly::to<std::string>(folly::getOSThreadID());
auto name = name_ + ":" + thid;
detectors_.wlock()->insert_or_assign(
h, deadlockDetectorFactory_->create(eventBase, name_));
h, deadlockDetectorFactory_->create(eventBase, name));
}

void IOThreadPoolDeadlockDetectorObserver::threadStopped(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
*/

#include <memory>

#include <fmt/core.h>

#include <folly/concurrency/DeadlockDetector.h>
#include <folly/executors/IOThreadPoolDeadlockDetectorObserver.h>
#include <folly/executors/IOThreadPoolExecutor.h>
Expand All @@ -39,7 +42,9 @@ class DeadlockDetectorFactoryMock : public DeadlockDetectorFactory {
std::unique_ptr<DeadlockDetector> create(
folly::Executor* executor, const std::string& name) override {
EXPECT_TRUE(executor != nullptr);
EXPECT_EQ("TestPool", name);
std::string expectedName =
fmt::format("TestPool:{}", folly::getOSThreadID());
EXPECT_EQ(expectedName, name);
return std::make_unique<DeadlockDetectorMock>(counter_);
}

Expand Down

0 comments on commit 61e00b1

Please sign in to comment.