You are viewing a plain text version of this content. The canonical link for it is here.
Posted to devnull@infra.apache.org by "jon-wei (GitHub)" <gi...@apache.org> on 2018/08/21 17:37:43 UTC

[GitHub] [incubator-druid] jon-wei opened issue #6201: Deadlock on overlord with HttpRemoteTaskRunner

We noticed deadlocks on the overlord in our test cluster, which was using HttpRemoteTaskRunner:

```
"hrtr-pending-tasks-runner-0" #193 daemon prio=5 os_prio=0 tid=0x00007fc5a8020000 nid=0x72ec waiting for monitor entry [0x00007fc5644b4000]
   java.lang.Thread.State: BLOCKED (on object monitor)
        at io.druid.indexing.overlord.hrtr.HttpRemoteTaskRunner.runTaskOnWorker(HttpRemoteTaskRunner.java:379)
        - waiting to lock <0x00000000c1544c10> (a java.lang.Object)
        at io.druid.indexing.overlord.hrtr.HttpRemoteTaskRunner.lambda$addPendingTaskToExecutor$7(HttpRemoteTaskRunner.java:1005)
        at io.druid.indexing.overlord.hrtr.HttpRemoteTaskRunner$$Lambda$133/748833484.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
```

```
java.lang.Thread.State: BLOCKED (on object monitor)
        at io.druid.indexing.overlord.hrtr.HttpRemoteTaskRunner.getKnownTasks(HttpRemoteTaskRunner.java:1111)
        - waiting to lock <0x00000000c1544c10> (a java.lang.Object)
        at io.druid.indexing.overlord.TaskQueue.manage(TaskQueue.java:232)
        at io.druid.indexing.overlord.TaskQueue.access$000(TaskQueue.java:69)
        at io.druid.indexing.overlord.TaskQueue$1.run(TaskQueue.java:136)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
```

```
"HttpRemoteTaskRunner-worker-sync-4" #116 daemon prio=5 os_prio=0 tid=0x00007fc588018800 nid=0x724c waiting for monitor entry [0x00007fc569801000]
   java.lang.Thread.State: BLOCKED (on object monitor)
        at io.druid.server.coordination.ChangeRequestHttpSyncer.stop(ChangeRequestHttpSyncer.java:138)
        - waiting to lock <0x00000000c1544980> (a io.druid.concurrent.LifecycleLock)
        at io.druid.indexing.overlord.hrtr.WorkerHolder.stop(WorkerHolder.java:333)
        at io.druid.indexing.overlord.hrtr.HttpRemoteTaskRunner.removeWorker(HttpRemoteTaskRunner.java:532)
        - locked <0x00000000c1540300> (a java.util.concurrent.ConcurrentHashMap)
        at io.druid.indexing.overlord.hrtr.HttpRemoteTaskRunner.lambda$scheduleSyncMonitoring$2(HttpRemoteTaskRunner.java:642)
        - locked <0x00000000c1540300> (a java.util.concurrent.ConcurrentHashMap)
        at io.druid.indexing.overlord.hrtr.HttpRemoteTaskRunner$$Lambda$90/1851975649.run(Unknown Source)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
```

```
java.lang.Thread.State: BLOCKED (on object monitor)
        at io.druid.indexing.overlord.hrtr.HttpRemoteTaskRunner.taskAddedOrUpdated(HttpRemoteTaskRunner.java:1174)
        - waiting to lock <0x00000000c1544c10> (a java.lang.Object)
        at io.druid.indexing.overlord.hrtr.HttpRemoteTaskRunner$$Lambda$87/935105358.taskAddedOrUpdated(Unknown Source)
        at io.druid.indexing.overlord.hrtr.WorkerHolder$2.notifyListener(WorkerHolder.java:449)
        at io.druid.indexing.overlord.hrtr.WorkerHolder$2.deltaSync(WorkerHolder.java:442)
        at io.druid.server.coordination.ChangeRequestHttpSyncer$1.onSuccess(ChangeRequestHttpSyncer.java:269)
        - locked <0x00000000c1543b50> (a io.druid.concurrent.LifecycleLock)
        at io.druid.server.coordination.ChangeRequestHttpSyncer$1.onSuccess(ChangeRequestHttpSyncer.java:225)
        at com.google.common.util.concurrent.Futures$4.run(Futures.java:1181)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
```

[ Full content available at: https://github.com/apache/incubator-druid/issues/6201 ]
This message was relayed via gitbox.apache.org for devnull@infra.apache.org

[GitHub] [incubator-druid] gianm closed issue #6201: Deadlock on overlord with HttpRemoteTaskRunner

Posted by "gianm (GitHub)" <gi...@apache.org>.
[ issue closed by gianm ]

[ Full content available at: https://github.com/apache/incubator-druid/issues/6201 ]
This message was relayed via gitbox.apache.org for devnull@infra.apache.org

[GitHub] [incubator-druid] himanshug commented on issue #6201: Deadlock on overlord with HttpRemoteTaskRunner

Posted by "himanshug (GitHub)" <gi...@apache.org>.
@jon-wei do you have full thread dump ? above shows threads waiting to get hold of locks but doesn't show which threads have the hold of lock (that might indicate why the locks are not getting freed up for others).

[ Full content available at: https://github.com/apache/incubator-druid/issues/6201 ]
This message was relayed via gitbox.apache.org for devnull@infra.apache.org

[GitHub] [incubator-druid] himanshug commented on issue #6201: Deadlock on overlord with HttpRemoteTaskRunner

Posted by "himanshug (GitHub)" <gi...@apache.org>.
great, that helps.

I think I understand the problem. HRTR is calling notification on attached listeners while still holding the `statusLock` , those listener's reaction ends up doing something that needs `statusLock` . Solution would be to call the listeners without holding `statusLock` .
which means `TaskRunnerUtils.notifyXX` should be called outside the lock. It has the mechanism to run listener in an executor service, but it appears `SameThreadExecutor` is used everywhere.
 I will raise a PR sometime soon.

[ Full content available at: https://github.com/apache/incubator-druid/issues/6201 ]
This message was relayed via gitbox.apache.org for devnull@infra.apache.org

[GitHub] [incubator-druid] himanshug commented on issue #6201: Deadlock on overlord with HttpRemoteTaskRunner

Posted by "himanshug (GitHub)" <gi...@apache.org>.
@jon-wei do you have full thread dump ? above shows threads waiting to get hold of locks but doesn't show which threads have the hold of the lock (that might indicate why the locks are not getting freed up for others).

[ Full content available at: https://github.com/apache/incubator-druid/issues/6201 ]
This message was relayed via gitbox.apache.org for devnull@infra.apache.org

[GitHub] [incubator-druid] jihoonson commented on issue #6201: Deadlock on overlord with HttpRemoteTaskRunner

Posted by "jihoonson (GitHub)" <gi...@apache.org>.
Here it is: [http-remote-task-runner-jstack.txt](https://github.com/apache/incubator-druid/files/2307787/http-remote-task-runner-jstack.txt)

It looks like HttpRemoteTaskRunner and TaskQueue blocks each other.

[ Full content available at: https://github.com/apache/incubator-druid/issues/6201 ]
This message was relayed via gitbox.apache.org for devnull@infra.apache.org

[GitHub] [incubator-druid] himanshug commented on issue #6201: Deadlock on overlord with HttpRemoteTaskRunner

Posted by "himanshug (GitHub)" <gi...@apache.org>.
great, that helps.

I think I understand the problem. HRTR is calling notification on attached listeners while still holding the `statusLock` , those listener's reaction ends up doing something that needs `statusLock` . Solution would be to call the listeners without holding `statusLock` . I will raise a PR sometime soon.

[ Full content available at: https://github.com/apache/incubator-druid/issues/6201 ]
This message was relayed via gitbox.apache.org for devnull@infra.apache.org

[GitHub] [incubator-druid] himanshug commented on issue #6201: Deadlock on overlord with HttpRemoteTaskRunner

Posted by "himanshug (GitHub)" <gi...@apache.org>.
great, that helps.

I think I understand the problem. HRTR is calling notification on attached listeners while still holding the `statusLock` , those listener's reaction ends up doing something that needs `statusLock` . Solution would be to call the listener's without holding `statusLock` . I will raise a PR sometime soon.

[ Full content available at: https://github.com/apache/incubator-druid/issues/6201 ]
This message was relayed via gitbox.apache.org for devnull@infra.apache.org