If N op_tp threads are configured, and recovery_max_active
is set to a sufficiently large number, all N op_tp threads
might grab a MOSDPGPush op off of the queue for the same PG.
The last thread to get the lock will have waited
N*time_to_handle_push before completing its item and pinging
the heartbeat timeout. If that time exceeds the timeout
and there are enough ops waiting, each thread subsequently
will end up exceeding the timeout before completeing an
item preventing the OSD from heartbeating indefinitely.
We prevent this by suspending the timeout while we try to
get the PG lock. Even if we do block for an excessive
period of time attempting to get the lock, hopefully,
the thread holding the lock will cause the threadpool
to time out.
Signed-off-by: Samuel Just <sam.just@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
}
}
+void ThreadPool::TPHandle::suspend_tp_timeout()
+{
+ cct->get_heartbeat_map()->clear_timeout(hb);
+}
+
void ThreadPool::TPHandle::reset_tp_timeout()
{
cct->get_heartbeat_map()->reset_timeout(
: cct(cct), hb(hb), grace(grace), suicide_grace(suicide_grace) {}
public:
void reset_tp_timeout();
+ void suspend_tp_timeout();
};
private:
return pg;
}
-void OSD::OpWQ::_process(PGRef pg)
+void OSD::OpWQ::_process(PGRef pg, ThreadPool::TPHandle &handle)
{
- pg->lock();
+ pg->lock_suspend_timeout(handle);
OpRequestRef op;
{
Mutex::Locker l(qlock);
bool _empty() {
return pqueue.empty();
}
- void _process(PGRef pg);
+ void _process(PGRef pg, ThreadPool::TPHandle &handle);
} op_wq;
void enqueue_op(PG *pg, OpRequestRef op);
#endif
}
+void PG::lock_suspend_timeout(ThreadPool::TPHandle &handle)
+{
+ handle.suspend_tp_timeout();
+ lock();
+ handle.reset_tp_timeout();
+}
+
void PG::lock(bool no_lockdep)
{
_lock.Lock(no_lockdep);
public:
bool deleting; // true while in removing or OSD is shutting down
+
+ void lock_suspend_timeout(ThreadPool::TPHandle &handle);
void lock(bool no_lockdep = false);
void unlock() {
//generic_dout(0) << this << " " << info.pgid << " unlock" << dendl;