Trouble running ElasticSearch in java test with numeric facets and multiple shards

Hi,
We seem to have stumbled on some issue while running queries against a
local elasticsearch node under a JUnit test.

We've been able to create a small test case which demonstrates this.

The necessary prerequisites for the failure:

  • 2 or more shards
  • Any of the DFS search types
  • A terms facet on a field with a "long" type in the mapping

We have tested it with elasticsearch 0.90.x, and different versions of java.

It doesn't always fail, e.g. we have one machine with an old java version
(1.7.0_07) where it works in IntelliJ, but not in maven.

When we run the test against the master-branch the test works, but not on
the 0.90-branch.

public class MyTest {
    private Client client;

    @Before
    public void createNode() throws Exception {
        Settings nodeSettings = ImmutableSettings.settingsBuilder()
                .put("node.local", false)
                .put("path.data", "./target/elasticsearch-test/data")
                .put("path.work", "./target/elasticsearch-test/work")
                .put("path.logs", "./target/elasticsearch-test/logs")
                .put("index.number_of_shards", "2")
                .build();

        Node node = NodeBuilder.nodeBuilder().settings(nodeSettings).node();
        client = node.client();
    }

    @After
    public void cleanup() throws Exception {
        FileSystemUtils.deleteRecursively(new 
File("./target/elasticsearch-test/"), true);
    }

    @Test
    public void demonstrateFailure() throws Exception {

        IndexResponse indexResponse = client
                .prepareIndex("test-index", "test-type")
                .setSource("{ \"id\": 123, \"test-value\": 321 }")
                .setRefresh(true)
                .execute()
                .actionGet();

        SearchResponse searchResponse = client
                .prepareSearch("test-index")
                .setQuery(new MatchAllQueryBuilder())
                .addFacet(new 
TermsFacetBuilder("test-facet").field("test-value"))
                .setSearchType(SearchType.DFS_QUERY_AND_FETCH)
                .execute()
                .actionGet();

        System.out.println(searchResponse);

        assertEquals(searchResponse.getFailedShards(), 0); // Failing!
    }
}

Output from a failed run:

{
  "took" : 68,
  "timed_out" : false,
  "_shards" : {
    "total" : 2,
    "successful" : 0,
    "failed" : 2,
    "failures" : [ {
      "index" : "test-index",
      "shard" : 0,
      "status" : 500,
      "reason" : "ElasticSearchException; nested: AssertionError; "
    }, {
      "index" : "test-index",
      "shard" : 1,
      "status" : 500,
      "reason" : "ElasticSearchException; nested: AssertionError; "
    } ]
  },
  "hits" : {
    "total" : 0,
    "max_score" : 0.0,
    "hits" : [ ]
  }
}

--

Regards,
Henrik Nordvik

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/b511afef-4461-477e-a46f-5c3c7f9cdedd%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Here are my findings:

The assertion error is

Caused by: java.lang.AssertionError
at
org.elasticsearch.common.recycler.ThreadLocalRecycler$TV.release(ThreadLocalRecycler.java:84)
at
org.elasticsearch.search.facet.terms.longs.TermsLongFacetExecutor.buildFacet(TermsLongFacetExecutor.java:104)
at org.elasticsearch.search.facet.FacetPhase.execute(FacetPhase.java:200)
at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:129)
at
org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:357)

It works in ES <= 0.90.3 but not in ES > 0.90.3 (also not in ES 1.0.0+) and
is specific to the combination of faceting with long values and DFS search
type.

Number of shards does not matter.

mvn --version
Apache Maven 3.1.0 (893ca28a1da9d5f51ac03827af98bb730128f9f2; 2013-06-28
04:15:32+0200)
Maven home: /usr/share/maven
Java version: 1.6.0_65, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: de_DE, platform encoding: MacRoman
OS name: "mac os x", version: "10.8.5", arch: "x86_64", family: "mac"

Jörg

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAKdsXoFWjJiL%2BM%3DsSEOX2gOvepiJe164y0pzKQb-x4UUSqpM-g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.