Indexing problem: java.lang.ArrayIndexOutOfBoundsException: -48

Hi again.
While indexing my documents the following problem occured:

[2011-07-06 05:34:33,187][DEBUG][action.bulk ] [Astra]
[201009][4]: Failed to execute bulk item (index) [index {[201009]
[message][211d779c-4e6c-4f9b-b74e-5cc502854732], source[{"messageId":
["211d779c-4e6c-4f9b-b74e-5cc502854732"],"sourceEndpoint":["81940f97-
e84c-42f8-b215-3809d08d69d8"],"destinationEndpoint":
["EA217E80-2CE4-11DA-8F53-5BDB61D1C73E"],"dateCreated":"2010-09-24T01:30:31.305Z","messageState":
[20],"documentId":["FV/13025/10/KARCZ01"],"messageType":[7]}]}]
java.lang.ArrayIndexOutOfBoundsException: -48
at
org.elasticsearch.index.engine.robin.RobinEngine.dirtyLock(RobinEngine.java:
948)
at
org.elasticsearch.index.engine.robin.RobinEngine.innerIndex(RobinEngine.java:
388)
at
org.elasticsearch.index.engine.robin.RobinEngine.index(RobinEngine.java:
374)
at
org.elasticsearch.index.shard.service.InternalIndexShard.index(InternalIndexShard.java:
292)
at
org.elasticsearch.action.bulk.TransportShardBulkAction.shardOperationOnPrimary(TransportShardBulkAction.java:
131)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction
$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:
418)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction
$AsyncShardOperationAction.access
$100(TransportShardReplicationOperationAction.java:233)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction
$AsyncShardOperationAction
$1.run(TransportShardReplicationOperationAction.java:331)
at java.util.concurrent.ThreadPoolExecutor
$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

That happens for only one document. Any idea why I happened?

The doc seems to be visible using:
curl -XGET 172.17.0.223:9200/201009/message/211d779c-4e6c-4f9b-
b74e-5cc502854732?pretty=1
{
"_index" : "201009",
"_type" : "message",
"_id" : "211d779c-4e6c-4f9b-b74e-5cc502854732"
}

But it is not visible by _search.

Anyway, is there any possibility to know about this exception on the
client side?
Invoking BulkResponse#hasFailures() will be enought in case on some
problems on the server side?

Ok, it seems to be a bug in ES 0.16.2 (unfortulately)

Simple use case shows that it is true:

curl -XPUT localhost:9200/test/message/211d779c-4e6c-4f9b-
b74e-5cc502854732 -d '
{
"test":"test"
}'

{"error":"ArrayIndexOutOfBoundsException[-48]","status":500}

curl -XPUT localhost:9200/test/message1/211d779c-4e6c-4f9b-
b74e-5cc502854732 -d '
{
"test":"test"
}'

Changing index type name or key makes the index to be properly
persist.

curl -XPUT localhost:9200/test/message1/211d779c-4e6c-4f9b-
b74e-5cc502854732 -d '
{
"test":"test"
}'
{"ok":true,"_index":"test","_type":"message1","_id":"211d779c-4e6c-4f9b-
b74e-5cc502854732","_version":2}

curl -XPUT localhost:9200/test/message/211d779c-4e6c-4f9b-
b74e-5cc502854731 -d '
{
"test":"test"
}'
{"ok":true,"_index":"test","_type":"message","_id":"211d779c-4e6c-4f9b-
b74e-5cc502854731","_version":2}

The problematic line is:
return dirtyLocks[Math.abs(uid.hashCode()) % dirtyLocks.length];

So when uid.hashCode() returns Integer.MIN_VALUE then this negative
value is returned. Which means that modulo also returns negative value
(wrong).

yea :), pushed a fix for master, will backport to 0.16 branch as well...

On Wednesday, July 6, 2011 at 11:35 AM, scoro wrote:

Ok, it seems to be a bug in ES 0.16.2 (unfortulately)

Simple use case shows that it is true:

curl -XPUT localhost:9200/test/message/211d779c-4e6c-4f9b-
b74e-5cc502854732 -d '
{
"test":"test"
}'

{"error":"ArrayIndexOutOfBoundsException[-48]","status":500}

curl -XPUT localhost:9200/test/message1/211d779c-4e6c-4f9b-
b74e-5cc502854732 -d '
{
"test":"test"
}'

Changing index type name or key makes the index to be properly
persist.

curl -XPUT localhost:9200/test/message1/211d779c-4e6c-4f9b-
b74e-5cc502854732 -d '
{
"test":"test"
}'
{"ok":true,"_index":"test","_type":"message1","_id":"211d779c-4e6c-4f9b-
b74e-5cc502854732","_version":2}

curl -XPUT localhost:9200/test/message/211d779c-4e6c-4f9b-
b74e-5cc502854731 -d '
{
"test":"test"
}'
{"ok":true,"_index":"test","_type":"message","_id":"211d779c-4e6c-4f9b-
b74e-5cc502854731","_version":2}

The problematic line is:
return dirtyLocks[Math.abs(uid.hashCode()) % dirtyLocks.length];

So when uid.hashCode() returns Integer.MIN_VALUE then this negative
value is returned. Which means that modulo also returns negative value
(wrong).