zipkin-storage-elasticsearch:1.17 not compatible with Elasticsearch 5.x #1431

Open
jamesbee opened this Issue Dec 9, 2016 · 4 comments

Projects

None yet

2 participants

@jamesbee
jamesbee commented Dec 9, 2016

hi, everyone.

spoiler: poor english incoming.

I'm using embedded zipkin-server for a application insight server. Last week i upgrade elasticsearch products to 5.x for filebeats's new feature like streaming over kafka. Then i got caught by a internal server error when query Span:

// ignore spring call stack
Caused by: java.lang.NoClassDefFoundError: org/elasticsearch/search/aggregations/bucket/terms/TermsBuilder
	at zipkin.storage.elasticsearch.ElasticsearchStorage.computeGuavaSpanStore(ElasticsearchStorage.java:140) ~[zipkin-storage-elasticsearch-1.17.1.jar:na]
	at zipkin.storage.elasticsearch.ElasticsearchStorage.computeGuavaSpanStore(ElasticsearchStorage.java:26) ~[zipkin-storage-elasticsearch-1.17.1.jar:na]
	at zipkin.storage.guava.LazyGuavaStorageComponent$1.compute(LazyGuavaStorageComponent.java:30) ~[zipkin-guava-1.17.1.jar:na]
	at zipkin.storage.guava.LazyGuavaStorageComponent$1.compute(LazyGuavaStorageComponent.java:27) ~[zipkin-guava-1.17.1.jar:na]
	at zipkin.internal.Lazy.tryCompute(Lazy.java:50) ~[zipkin-1.17.1.jar:na]
	at zipkin.internal.Lazy.get(Lazy.java:37) ~[zipkin-1.17.1.jar:na]
	at zipkin.storage.guava.LazyGuavaStorageComponent.guavaSpanStore(LazyGuavaStorageComponent.java:40) ~[zipkin-guava-1.17.1.jar:na]
	at zipkin.storage.guava.GuavaStorageComponent.asyncSpanStore(GuavaStorageComponent.java:30) ~[zipkin-guava-1.17.1.jar:na]
	at zipkin.storage.guava.GuavaStorageComponent.spanStore(GuavaStorageComponent.java:26) ~[zipkin-guava-1.17.1.jar:na]
	at zipkin.server.ZipkinQueryApiV1.getServiceNames(ZipkinQueryApiV1.java:75) ~[zipkin-server-1.17.1.jar:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_60]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_60]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_60]
	at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_60]
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:220) ~[spring-web-4.3.4.RELEASE.jar:4.3.4.RELEASE]
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:134) ~[spring-web-4.3.4.RELEASE.jar:4.3.4.RELEASE]
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116) ~[spring-webmvc-4.3.4.RELEASE.jar:4.3.4.RELEASE]
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) ~[spring-webmvc-4.3.4.RELEASE.jar:4.3.4.RELEASE]
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) ~[spring-webmvc-4.3.4.RELEASE.jar:4.3.4.RELEASE]
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.3.4.RELEASE.jar:4.3.4.RELEASE]
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) [spring-webmvc-4.3.4.RELEASE.jar:4.3.4.RELEASE]
	... 56 common frames omitted
// ignore class loader call stack

TermsBuilder used in ES 2.x and deprecated in 5.x.

I do some research and find ES 5.x supported in #1403 , seems no one had crushed to this exception yet.

Then i looked into decompiled class file, i suppose the reason cause this exception is :

// decompiled class file
// zipkin.storage.elasticsearch.ElasticsearchSpanStore#getSpanNames
public ListenableFuture<List<String>> getSpanNames(String serviceName) {
    if(Strings.isNullOrEmpty(serviceName)) {
        return EMPTY_LIST;
    } else {
        serviceName = serviceName.toLowerCase();
        BoolQueryBuilder filter = QueryBuilders.boolQuery().should(QueryBuilders.nestedQuery("annotations", QueryBuilders.termQuery("annotations.endpoint.serviceName", serviceName))).should(QueryBuilders.nestedQuery("binaryAnnotations", QueryBuilders.termQuery("binaryAnnotations.endpoint.serviceName", serviceName)));
        return this.client.collectBucketKeys(this.catchAll, 
          QueryBuilders.boolQuery().must(QueryBuilders.matchAllQuery()).filter(filter),

          // this `(TermsBuilder)` type cast cause NoClassDefFoundError

          new AbstractAggregationBuilder[]{((TermsBuilder)AggregationBuilders.terms("name_agg").order(Order.term(true)).field("name")).size(2147483647)});
    }
}

Although zipkin-storage-elasticsearch is written in es 2.x & 5.x compatible format, but the compiled class added this type cast transparently by javac 😂

sooo.... any idea?

@adriancole
Contributor
@jamesbee
jamesbee commented Dec 9, 2016

Got it, thanks a lot! :>

@adriancole
Contributor

sorry lost track of this

@adriancole adriancole added a commit that referenced this issue Jan 17, 2017
@adriancole adriancole Begins migration off Elasticsearch 2.x library (and Guava)
Currently, our Elasticsearch 2.x dependency makes it impossible to load
recent versions of Elasticsearch or Guava.

This begins work to migrate off by porting write and health code to not
use guava types.

See #1431
f3bb89b
@adriancole
Contributor

starting this now.. I suspect it will take all week to move off the old library #1495

@adriancole adriancole added a commit that referenced this issue Jan 18, 2017
@adriancole adriancole Begins migration off Elasticsearch 2.x library (and Guava)
Currently, our Elasticsearch 2.x dependency makes it impossible to load
recent versions of Elasticsearch or Guava.

This begins work to migrate off by porting write and health code to not
use guava types.

See #1431
fa2bb6e
@adriancole adriancole added a commit that referenced this issue Jan 18, 2017
@adriancole adriancole Begins migration off Elasticsearch 2.x library (and Guava) (#1495)
Currently, our Elasticsearch 2.x dependency makes it impossible to load
recent versions of Elasticsearch or Guava.

This begins work to migrate off by porting write and health code to not
use guava types.

See #1431
b543f09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment