IndexMissingException on create index followed by refresh


(Sebastian Gavarini) #1

Hi, I am seeing an IndexMissingException when I do an index create
followed immediately by refresh.

first of all, my setup is:

  • ES 0.12.1
  • Java client API, embedded no-data node
  • local gateway
  • remote ES data node

My pseudocode goes like this:

  • create index (1 shard, 0 replica for batch indexing)
  • add documents if any
  • refresh
  • flush
  • optimize
    ...
    In my first attempt I didn't have documents in my DB, so create was
    followed by refresh without delay, in that case I am seeing:

Exception in thread "Thread-6"
org.elasticsearch.indices.IndexMissingException: [index-dev-v0]
missing
at
org.elasticsearch.cluster.routing.RoutingTable.allShardsGrouped(RoutingTable.java:
153)
at
org.elasticsearch.action.admin.indices.refresh.TransportRefreshAction.shards(TransportRefreshAction.java:
116)
at
org.elasticsearch.action.admin.indices.refresh.TransportRefreshAction.shards(TransportRefreshAction.java:
50)
at
org.elasticsearch.action.support.broadcast.TransportBroadcastOperationAction
$AsyncBroadcastAction.(TransportBroadcastOperationAction.java:
161)
at
org.elasticsearch.action.support.broadcast.TransportBroadcastOperationAction.doExecute(TransportBroadcastOperationAction.java:
77)
at
org.elasticsearch.action.support.broadcast.TransportBroadcastOperationAction.doExecute(TransportBroadcastOperationAction.java:
54)
at
org.elasticsearch.action.support.BaseAction.execute(BaseAction.java:
54)
at
org.elasticsearch.action.support.BaseAction.execute(BaseAction.java:
43)
at
org.elasticsearch.client.node.NodeIndicesAdminClient.refresh(NodeIndicesAdminClient.java:
147)

When I call create index I wait for the future to finish with:
CreateIndexResponse response = future.actionGet();
When using "curl" to the remote ES node I can see the index is in fact
created, contrary to the exception.

If I add a 100ms delay in the "add documents" step everything works
OK, that's why I think it must be a concurrency issue, locking bug or
the like.

I understand that creating an index and then refreshing it is
pointless, I expect "add documents" to actually add some, but in this
case the DB was still empty and this weird thing happened. I could add
some checks in my code for that case, but I think it must be a tiny
bug that's better tackled. I could help with more details or tests if
somebody wishes to trace the problem.

Thanks,
Sebastian.


Time lag between Index creation and Index availability
(Shay Banon) #2

Hi,

Let me explain why this happens. When creating an index, the creation
itself happens on the master node, and the fact that it gets created is
published to all the other nodes (including the client node). If you try and
do a refresh right after, the fact that the index was created might not have
gotten to the client node you are working with. The create index does wait
for all the changes to be sent to the clients, but not for it to be applied.

Some operation do wait for an index if it has not been created, like

index and delete, as they have timeouts. Others, like get / refresh do not
(as it make little sense for them to wait, the index name might be wrong).

You can try and explicitly create the index, and then wait using the

cluster health API for at least a yellow status. Its usually a good practice
(your recovery might take time).

Its something that needs to be solved. Not that simple because of its

distributed nature. I have some ideas on how to solve it without causing to
much load on the cluster... .

-shay.banon

On Wed, Nov 3, 2010 at 6:52 AM, Sebastian sgavarini@gmail.com wrote:

Hi, I am seeing an IndexMissingException when I do an index create
followed immediately by refresh.

first of all, my setup is:

  • ES 0.12.1
  • Java client API, embedded no-data node
  • local gateway
  • remote ES data node

My pseudocode goes like this:

  • create index (1 shard, 0 replica for batch indexing)
  • add documents if any
  • refresh
  • flush
  • optimize
    ...
    In my first attempt I didn't have documents in my DB, so create was
    followed by refresh without delay, in that case I am seeing:

Exception in thread "Thread-6"
org.elasticsearch.indices.IndexMissingException: [index-dev-v0]
missing
at

org.elasticsearch.cluster.routing.RoutingTable.allShardsGrouped(RoutingTable.java:
153)
at

org.elasticsearch.action.admin.indices.refresh.TransportRefreshAction.shards(TransportRefreshAction.java:
116)
at

org.elasticsearch.action.admin.indices.refresh.TransportRefreshAction.shards(TransportRefreshAction.java:
50)
at

org.elasticsearch.action.support.broadcast.TransportBroadcastOperationAction
$AsyncBroadcastAction.(TransportBroadcastOperationAction.java:
161)
at

org.elasticsearch.action.support.broadcast.TransportBroadcastOperationAction.doExecute(TransportBroadcastOperationAction.java:
77)
at

org.elasticsearch.action.support.broadcast.TransportBroadcastOperationAction.doExecute(TransportBroadcastOperationAction.java:
54)
at
org.elasticsearch.action.support.BaseAction.execute(BaseAction.java:
54)
at
org.elasticsearch.action.support.BaseAction.execute(BaseAction.java:
43)
at

org.elasticsearch.client.node.NodeIndicesAdminClient.refresh(NodeIndicesAdminClient.java:
147)

When I call create index I wait for the future to finish with:
CreateIndexResponse response = future.actionGet();
When using "curl" to the remote ES node I can see the index is in fact
created, contrary to the exception.

If I add a 100ms delay in the "add documents" step everything works
OK, that's why I think it must be a concurrency issue, locking bug or
the like.

I understand that creating an index and then refreshing it is
pointless, I expect "add documents" to actually add some, but in this
case the DB was still empty and this weird thing happened. I could add
some checks in my code for that case, but I think it must be a tiny
bug that's better tackled. I could help with more details or tests if
somebody wishes to trace the problem.

Thanks,
Sebastian.


(system) #3