assert(m_workers.empty());
}
-heartbeat_handle_d *HeartbeatMap::add_worker(const string& name)
+heartbeat_handle_d *HeartbeatMap::add_worker(const string& name, pthread_t thread_id)
{
m_rwlock.get_write();
ldout(m_cct, 10) << "add_worker '" << name << "'" << dendl;
"heartbeat_handle_d suicide_timeout");
m_workers.push_front(h);
h->list_item = m_workers.begin();
+ h->thread_id = thread_id;
m_rwlock.put_write();
return h;
}
if (was && was < now) {
ldout(m_cct, 1) << who << " '" << h->name << "'"
<< " had suicide timed out after " << h->suicide_grace << dendl;
+ pthread_kill(h->thread_id, SIGABRT);
+ sleep(1);
assert(0 == "hit suicide timeout");
}
return healthy;
struct heartbeat_handle_d {
const std::string name;
+ pthread_t thread_id;
atomic_t timeout, suicide_timeout;
time_t grace, suicide_grace;
std::list<heartbeat_handle_d*>::iterator list_item;
explicit heartbeat_handle_d(const std::string& n)
- : name(n), grace(0), suicide_grace(0)
+ : name(n), thread_id(0), grace(0), suicide_grace(0)
{ }
};
class HeartbeatMap {
public:
// register/unregister
- heartbeat_handle_d *add_worker(const std::string& name);
+ heartbeat_handle_d *add_worker(const std::string& name, pthread_t thread_id);
void remove_worker(const heartbeat_handle_d *h);
// reset the timeout so that it expects another touch within grace amount of time
std::stringstream ss;
ss << name << " thread " << (void*)pthread_self();
- heartbeat_handle_d *hb = cct->get_heartbeat_map()->add_worker(ss.str());
+ heartbeat_handle_d *hb = cct->get_heartbeat_map()->add_worker(ss.str(), pthread_self());
while (!_stop) {
std::stringstream ss;
ss << name << " thread " << (void*)pthread_self();
- heartbeat_handle_d *hb = cct->get_heartbeat_map()->add_worker(ss.str());
+ heartbeat_handle_d *hb = cct->get_heartbeat_map()->add_worker(ss.str(), pthread_self());
while (!stop_threads.read()) {
if(pause_threads.read()) {
suicide_hook(suicide_hook_),
standby_replaying(false)
{
- hb = g_ceph_context->get_heartbeat_map()->add_worker("MDSRank");
+ hb = g_ceph_context->get_heartbeat_map()->add_worker("MDSRank", pthread_self());
finisher = new Finisher(msgr->cct);
TEST(HeartbeatMap, Healthy) {
HeartbeatMap hm(g_ceph_context);
- heartbeat_handle_d *h = hm.add_worker("one");
+ heartbeat_handle_d *h = hm.add_worker("one", pthread_self());
hm.reset_timeout(h, 9, 18);
bool healthy = hm.is_healthy();
TEST(HeartbeatMap, Unhealth) {
HeartbeatMap hm(g_ceph_context);
- heartbeat_handle_d *h = hm.add_worker("one");
+ heartbeat_handle_d *h = hm.add_worker("one", pthread_self());
hm.reset_timeout(h, 1, 3);
sleep(2);