No active shards in tests using the java api

Hi,

I'm currently working with jruby and the java elasticsearch api. To ensure
a clean index for every testcase, I delete, create and refresh the index
before every test.
This work's most of the time but sometimes I get the following exception:

org.elasticsearch.action.search.SearchPhaseExecutionException: Failed 

to execute phase [query_fetch], total failure; shardFailures
{[na][memento_test][0]: No active shards}

What I'm doing is basically:

    def reset(index_name)
      client.prepare_delete(index_name).execute.action_get
      client.prepare_create(index_name).execute.action_get
      client.prepare_refresh(index_name).execute.action_get
    end

Nothing fancy I guess...
I guess this is a timing problem but I currently can't think of a way to
work around this.
Any hints / best practices for these kind of test cleanups?

thanks!

-- pascal

--

Have you tried to wait for a Green/Yellow cluster status before executing
the tests/queries?

My 2 cents

-- Tanguy
twitter: @tlrx

Le mardi 16 octobre 2012 16:38:12 UTC+2, Pascal Friederich a écrit :

Hi,

I'm currently working with jruby and the java elasticsearch api. To ensure
a clean index for every testcase, I delete, create and refresh the index
before every test.
This work's most of the time but sometimes I get the following exception:

org.elasticsearch.action.search.SearchPhaseExecutionException: Failed 

to execute phase [query_fetch], total failure; shardFailures
{[na][memento_test][0]: No active shards}

What I'm doing is basically:

    def reset(index_name)
      client.prepare_delete(index_name).execute.action_get
      client.prepare_create(index_name).execute.action_get
      client.prepare_refresh(index_name).execute.action_get
    end

Nothing fancy I guess...
I guess this is a timing problem but I currently can't think of a way to
work around this.
Any hints / best practices for these kind of test cleanups?

thanks!

-- pascal

--

heya, not quite, but you hinted me into the right direction. I'm executing
a HealthRequest with waitForActiveShards(1) now. This seems to work so far

On Tuesday, October 16, 2012 5:12:02 PM UTC+2, Tanguy wrote:

Have you tried to wait for a Green/Yellow cluster status before executing
the tests/queries?

My 2 cents

-- Tanguy
twitter: @tlrx
tlrx (Tanguy Leroux) · GitHub

Le mardi 16 octobre 2012 16:38:12 UTC+2, Pascal Friederich a écrit :

Hi,

I'm currently working with jruby and the java elasticsearch api. To
ensure a clean index for every testcase, I delete, create and refresh the
index before every test.
This work's most of the time but sometimes I get the following exception:

org.elasticsearch.action.search.SearchPhaseExecutionException: Failed 

to execute phase [query_fetch], total failure; shardFailures
{[na][memento_test][0]: No active shards}

What I'm doing is basically:

    def reset(index_name)
      client.prepare_delete(index_name).execute.action_get
      client.prepare_create(index_name).execute.action_get
      client.prepare_refresh(index_name).execute.action_get
    end

Nothing fancy I guess...
I guess this is a timing problem but I currently can't think of a way to
work around this.
Any hints / best practices for these kind of test cleanups?

thanks!

-- pascal

--