IndexOutOfBoundsException in GridCacheWriteBehindStore Flusher thread lookup (IGNITE-14893)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

IndexOutOfBoundsException in GridCacheWriteBehindStore Flusher thread lookup (IGNITE-14893)

Ilya Korol
Hi, All.

I'm going to fix issue with IndexOutOfBoundsException in
GridCacheWriteBehindStore#flusher(K key) method.

https://issues.apache.org/jira/browse/IGNITE-14893

This could happen when flush thread count is not a power of 2 an we
fallback to mapping via modulo operation:


idx = ((h = key.hashCode()) ^ (h >>> 16)) % flushThreadCnt


I assume that to fix this issue, wrapping the whole expression to abs()
function should be enough. But since there is also a lot of places where
we need to perform hash -> array_index mappings, there also could be
potential bugs, if we forget to check incoming hash sign. So I guess
that it would be convenient to introduce dedicated method in IgniteUtils
class for such cases.


Any comments here?