thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Liu Lin (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (THRIFT-4004) ThreadManager deadlock when adding new task
Date Tue, 13 Dec 2016 09:27:59 GMT

     [ https://issues.apache.org/jira/browse/THRIFT-4004?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Liu Lin  updated THRIFT-4004:
-----------------------------
    Summary: ThreadManager deadlock when adding new task  (was: ThreadManager deadlock for
task expiration)

> ThreadManager deadlock when adding new task
> -------------------------------------------
>
>                 Key: THRIFT-4004
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4004
>             Project: Thrift
>          Issue Type: Bug
>          Components: C++ - Library
>    Affects Versions: 0.9.3
>            Reporter: Liu Lin 
>
> Set pendingTaskCountMax = 1. 
> Add only 1 worker into ThreadManager.
> When adding task, set timeout > 0.
> If there is no task, worker thread will sleep, because manager_->monitor_.wait(Line
259) invoked in function ThreadManager::Worker::run.
> Then suppose we have 2 tasks. We add the first task by calling ThreadManager::Impl::add,
which will nofity monitor_. But before manager_->monitor_.wait() returns, we call ThreadManager::Impl::add
again. If ThreadManager::Impl::add gets lock mutex_ successfully, ThreadManager::Worker::run
will fall asleep again because it can not lock mutex_.
> Now we have tasks_.size() == pendingTaskCountMax_, so ThreadManager::Impl::add will wait
on maxMonitor_(Line 462). Becasue the worker cannot fetch a task(because it can not lock mutex_,
it will not notify maxMonitor_), so ThreadManager::Impl::add will wait forever. 
> Now both the two threads wait for each other, result in deadlock. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message