[jira] [Commented] (KAFKA-3014) Integer overflow causes incorrect node iteration in leastLoadedNode()

2015-12-21 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/KAFKA-3014?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15066875#comment-15066875
 ] 

ASF GitHub Bot commented on KAFKA-3014:
---

Github user asfgit closed the pull request at:

https://github.com/apache/kafka/pull/696


> Integer overflow causes incorrect node iteration in leastLoadedNode() 
> --
>
> Key: KAFKA-3014
> URL: https://issues.apache.org/jira/browse/KAFKA-3014
> Project: Kafka
>  Issue Type: Bug
>Reporter: Jason Gustafson
>Assignee: Jason Gustafson
> Fix For: 0.9.0.1
>
>
> The leastLoadedNode() implementation iterates over all the known nodes to 
> find a suitable candidate for sending metadata. The loop looks like this:
> {code}
> for (int i = 0; i < nodes.size(); i++) {
>   int idx = Utils.abs((this.nodeIndexOffset + i) % nodes.size());
>   Node node = nodes.get(idx);
>   ...
> }
> {code}
> Unfortunately, this doesn't handle integer overflow correctly, which can 
> result in some nodes in the list being passed over. For example, if the size 
> of the node list is 5 and the random offset is Integer.MAX_VALUE, then the 
> loop will iterate over the following indices: 2, 3, 2, 1, 0. 
> In pathological cases, this can prevent the client from being able to connect 
> to good nodes in order to refresh metadata.



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


[jira] [Commented] (KAFKA-3014) Integer overflow causes incorrect node iteration in leastLoadedNode()

2015-12-18 Thread Ismael Juma (JIRA)

[ 
https://issues.apache.org/jira/browse/KAFKA-3014?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15064548#comment-15064548
 ] 

Ismael Juma commented on KAFKA-3014:


Nice catch!

> Integer overflow causes incorrect node iteration in leastLoadedNode() 
> --
>
> Key: KAFKA-3014
> URL: https://issues.apache.org/jira/browse/KAFKA-3014
> Project: Kafka
>  Issue Type: Bug
>Reporter: Jason Gustafson
>Assignee: Jason Gustafson
>
> The leastLoadedNode() implementation iterates over all the known nodes to 
> find a suitable candidate for sending metadata. The loop looks like this:
> {code}
> for (int i = 0; i < nodes.size(); i++) {
>   int idx = Utils.abs((this.nodeIndexOffset + i) % nodes.size());
>   Node node = nodes.get(idx);
>   ...
> }
> {code}
> Unfortunately, this doesn't handle integer overflow correctly, which can 
> result in some nodes in the list being passed over. For example, if the size 
> of the node list is 5 and the random offset is Integer.MAX_VALUE, then the 
> loop will iterate over the following indices: 2, 3, 2, 1, 0. 
> In pathological cases, this can prevent the client from being able to connect 
> to good nodes in order to refresh metadata.



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


[jira] [Commented] (KAFKA-3014) Integer overflow causes incorrect node iteration in leastLoadedNode()

2015-12-18 Thread Guozhang Wang (JIRA)

[ 
https://issues.apache.org/jira/browse/KAFKA-3014?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15064685#comment-15064685
 ] 

Guozhang Wang commented on KAFKA-3014:
--

This is great find!

> Integer overflow causes incorrect node iteration in leastLoadedNode() 
> --
>
> Key: KAFKA-3014
> URL: https://issues.apache.org/jira/browse/KAFKA-3014
> Project: Kafka
>  Issue Type: Bug
>Reporter: Jason Gustafson
>Assignee: Jason Gustafson
>
> The leastLoadedNode() implementation iterates over all the known nodes to 
> find a suitable candidate for sending metadata. The loop looks like this:
> {code}
> for (int i = 0; i < nodes.size(); i++) {
>   int idx = Utils.abs((this.nodeIndexOffset + i) % nodes.size());
>   Node node = nodes.get(idx);
>   ...
> }
> {code}
> Unfortunately, this doesn't handle integer overflow correctly, which can 
> result in some nodes in the list being passed over. For example, if the size 
> of the node list is 5 and the random offset is Integer.MAX_VALUE, then the 
> loop will iterate over the following indices: 2, 3, 2, 1, 0. 
> In pathological cases, this can prevent the client from being able to connect 
> to good nodes in order to refresh metadata.



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


[jira] [Commented] (KAFKA-3014) Integer overflow causes incorrect node iteration in leastLoadedNode()

2015-12-18 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/KAFKA-3014?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15064887#comment-15064887
 ] 

ASF GitHub Bot commented on KAFKA-3014:
---

GitHub user hachikuji opened a pull request:

https://github.com/apache/kafka/pull/696

KAFKA-3014: fix integer overflow problem in leastLoadedNode



You can merge this pull request into a Git repository by running:

$ git pull https://github.com/hachikuji/kafka KAFKA-3014

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/kafka/pull/696.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #696


commit d513df5a3e732cde7576a4a126ac137045e1046c
Author: Jason Gustafson 
Date:   2015-12-18T22:18:07Z

KAFKA-3014: fix integer overflow problem in leastLoadedNode




> Integer overflow causes incorrect node iteration in leastLoadedNode() 
> --
>
> Key: KAFKA-3014
> URL: https://issues.apache.org/jira/browse/KAFKA-3014
> Project: Kafka
>  Issue Type: Bug
>Reporter: Jason Gustafson
>Assignee: Jason Gustafson
>
> The leastLoadedNode() implementation iterates over all the known nodes to 
> find a suitable candidate for sending metadata. The loop looks like this:
> {code}
> for (int i = 0; i < nodes.size(); i++) {
>   int idx = Utils.abs((this.nodeIndexOffset + i) % nodes.size());
>   Node node = nodes.get(idx);
>   ...
> }
> {code}
> Unfortunately, this doesn't handle integer overflow correctly, which can 
> result in some nodes in the list being passed over. For example, if the size 
> of the node list is 5 and the random offset is Integer.MAX_VALUE, then the 
> loop will iterate over the following indices: 2, 3, 2, 1, 0. 
> In pathological cases, this can prevent the client from being able to connect 
> to good nodes in order to refresh metadata.



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