[
https://issues.apache.org/jira/browse/KAFKA-4820?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Dong Lin updated KAFKA-4820:
----------------------------
Description:
Currently `ConsumerNetworkClient.send()` needs to acquire global lock of
`ConumserNetworkClient` in order to enqueue requests. If another thread has
called `ConsumerNetworkClient.poll(..)`, that thread may be holding the lock
while blocked on `nioSelector.select(ms)`. This causes problem because the user
thread which calls `ConsumerNetworkClient.send()` will also block waiting for
that `nioSelector.select(ms)` to finish.
One way to address this problem is to use `synchronized (unsent)` to protect
access to `ConsumeNetworkClient.unsent` instead of protecting it using a global
lock. So that user thread should be able to enqueue requests immediately while
another thread is blocked on `nioSelector.select(ms)`.
was:
Currently `ConsumerNetworkClient.send()` needs to acquire global lock of
`ConumserNetworkClient` in order to enqueue requests. If another thread has
called `ConsumerNetworkClient.poll(..)`, that thread may be holding the lock
while blocked on `nioSelector.select(ms)`. This causes problem because the user
thread which calls `ConsumerNetworkClient.send()` will also block waiting for
that `nioSelector.select(ms)` to finish.
One way to address this problem is to use thread-safe classes for the variable
`ConsumeNetworkClient.unsent` so that it is protected by its own lock. Then
`ConsumerNetworkClient.send()` will no longer require global lock in order to
enqueue request.
> ConsumerNetworkClient.send() should not require global lock
> -----------------------------------------------------------
>
> Key: KAFKA-4820
> URL: https://issues.apache.org/jira/browse/KAFKA-4820
> Project: Kafka
> Issue Type: Bug
> Reporter: Dong Lin
> Assignee: Dong Lin
>
> Currently `ConsumerNetworkClient.send()` needs to acquire global lock of
> `ConumserNetworkClient` in order to enqueue requests. If another thread has
> called `ConsumerNetworkClient.poll(..)`, that thread may be holding the lock
> while blocked on `nioSelector.select(ms)`. This causes problem because the
> user thread which calls `ConsumerNetworkClient.send()` will also block
> waiting for that `nioSelector.select(ms)` to finish.
> One way to address this problem is to use `synchronized (unsent)` to protect
> access to `ConsumeNetworkClient.unsent` instead of protecting it using a
> global lock. So that user thread should be able to enqueue requests
> immediately while another thread is blocked on `nioSelector.select(ms)`.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)