Synch wait for index deletion


(Steff) #1

Hi

When we create an index, we wait for the creation to finish before
continuing. We do the waiting using a health-request with
waitForYellowStatus on the newly created index. It seems to work fine.

When we delete an index, we would also like to wait for the deletion
to finish before continuing. We tried using health-request with
waitForYellowStatus on the deleted index. It seems to me like it is
not the right way to do it, because it seems like it always take
exactly 30 secs waiting for yellow status - it smells more like a
timeout we run into because it might not make sense to check for
yellow status on a deleted index.

AdminClient admin = client.admin();
DeleteIndexResponse response =
admin.indices().delete(Requests.deleteIndexRequest(indexName)).actionGet();
admin.cluster().health(new
ClusterHealthRequest(indexName).waitForYellowStatus()).actionGet();

Am I right? How can I wait for the deletion of an index to be finished
before continuing.

Regards, Per Steffensen


(Steff) #2

Hmmm, this was written directly on google-groups web-page. Why doesnt
it arrive as a mail on the mailing-list?

On Oct 3, 11:30 pm, Steff st...@designware.dk wrote:

Hi

When we create an index, we wait for the creation to finish before
continuing. We do the waiting using a health-request with
waitForYellowStatus on the newly created index. It seems to work fine.

When we delete an index, we would also like to wait for the deletion
to finish before continuing. We tried using health-request with
waitForYellowStatus on the deleted index. It seems to me like it is
not the right way to do it, because it seems like it always take
exactly 30 secs waiting for yellow status - it smells more like a
timeout we run into because it might not make sense to check for
yellow status on a deleted index.

AdminClient admin = client.admin();
DeleteIndexResponse response =
admin.indices().delete(Requests.deleteIndexRequest(indexName)).actionGet();
admin.cluster().health(new
ClusterHealthRequest(indexName).waitForYellowStatus()).actionGet();

Am I right? How can I wait for the deletion of an index to be finished
before continuing.

Regards, Per Steffensen


(Shay Banon) #3

I think there is a misunderstanding here on what waiting for yellow/green
status means. Let me explain:

When you create an index, the index creation goes to the master node, and
its handling the actual index creation, adding it to the cluster metadata,
do initial shard allocation (where the shards should go). It will also wait
for the index data structure to be created on the relevant nodes shards were
allocated to (if they are), but won't wait for shards to become started.

Waiting for yellow state after index creation means that are least one shard
(the primary) from each shard replication group has been started. Waiting
for green state means that you wait for all shards to be started (including
replicas).

The cluster health API does not block forever for this state, it waits by
default for 30s, and if the API has timed out, it is stated in the timed out
flag.

If you don't wait for yellow status after index creation, it might be ok
(depends on your usecase). When indexing, the index operation will wait for
a specific timeout until the primary shard it is designated to work on will
become available. When searching, it will not wait, but will simply return
failures for the relevant shards that were not available.

When deleting an index, its not really relevant to wait for yellow status.
The index has been deleted, there are no shards to wait to become active.
The delete index will block and wait for the index to be deleted from all
the nodes that have shards allocated for the relevant index you deleted.

On Mon, Oct 3, 2011 at 11:30 PM, Steff steff@designware.dk wrote:

Hi

When we create an index, we wait for the creation to finish before
continuing. We do the waiting using a health-request with
waitForYellowStatus on the newly created index. It seems to work fine.

When we delete an index, we would also like to wait for the deletion
to finish before continuing. We tried using health-request with
waitForYellowStatus on the deleted index. It seems to me like it is
not the right way to do it, because it seems like it always take
exactly 30 secs waiting for yellow status - it smells more like a
timeout we run into because it might not make sense to check for
yellow status on a deleted index.

AdminClient admin = client.admin();
DeleteIndexResponse response =
admin.indices().delete(Requests.deleteIndexRequest(indexName)).actionGet();
admin.cluster().health(new
ClusterHealthRequest(indexName).waitForYellowStatus()).actionGet();

Am I right? How can I wait for the deletion of an index to be finished
before continuing.

Regards, Per Steffensen


(system) #4