# When set the DocValueContext for FetchPhase became very slow

**URL:** <https://discuss.elastic.co/t/when-set-the-docvaluecontext-for-fetchphase-became-very-slow/175785>\
**Category:** Elasticsearch\
**Created:** [April 8, 2019, 8:06am UTC](https://discuss.elastic.co/t/when-set-the-docvaluecontext-for-fetchphase-became-very-slow/175785 "2019-04-08T08:06:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yunfeng\_wu](https://avatars.discourse-cdn.com/v4/letter/y/cdc98d/32.png) [@yunfeng\_wu](https://discuss.elastic.co/u/yunfeng_wu)\
**Post date:** [April 8, 2019, 8:06am UTC](https://discuss.elastic.co/t/when-set-the-docvaluecontext-for-fetchphase-became-very-slow/175785/1 "2019-04-08T08:06:34Z")

</div>

our plugins need read field value from `docvalue`, after query phase we set the `DocValueFieldsContext` contains the field we need. If field has no docvalue, we would retrieve this field value from `stored_fields` or `_source`. The whole query became very slowly, dump the proccess stack-trace we found thread stucked at **sun.reflect.Reflection.getCallerClass as below depicted** , can anyone explain this? Our plugins using thrift-RPC introduced slf4j-api-xxx.jar

```
java.lang.Thread.State: RUNNABLE
    at sun.reflect.Reflection.getCallerClass(Native Method)
    at java.lang.Class.getClassLoader(Class.java:683)
    at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:551)
    at org.elasticsearch.common.logging.ESLoggerFactory.getLogger(ESLoggerFactory.java:49)
    at org.elasticsearch.common.logging.ESLoggerFactory.getLogger(ESLoggerFactory.java:57)
    at org.elasticsearch.common.logging.Loggers.getLogger(Loggers.java:101)
    at org.elasticsearch.index.fielddata.plain.DocValuesIndexFieldData.<init>(DocValuesIndexFieldData.java:55)
    at org.elasticsearch.index.fielddata.plain.SortedNumericDVIndexFieldData.<init>(SortedNumericDVIndexFieldData.java:58)
    at org.elasticsearch.index.fielddata.plain.DocValuesIndexFieldData$Builder.build(DocValuesIndexFieldData.java:99)
    at org.elasticsearch.index.fielddata.IndexFieldDataService.getForField(IndexFieldDataService.java:129)
    at org.elasticsearch.search.fetch.subphase.DocValueFieldsFetchSubPhase.hitExecute(DocValueFieldsFetchSubPhase.java:64)
    at org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:162)
    at com.baidu.elasticsearch.scan.ScanService.executeFetchPhase(ScanService.java:313)
    at com.baidu.elasticsearch.scan.ScanService.getNext(ScanService.java:271)

```

Or

```
java.lang.Thread.State: RUNNABLE
    at sun.reflect.Reflection.getCallerClass(Native Method)
    at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.logging.log4j.util.ReflectionUtil.getCallerClass(ReflectionUtil.java:129)
    at org.apache.logging.log4j.util.ReflectionUtil.getCallerClass(ReflectionUtil.java:212)
    at org.apache.logging.log4j.util.ReflectionUtil.getCallerClass(ReflectionUtil.java:203)
    at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:72)
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:227)
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
    at org.apache.logging.log4j.LogManager.getContext(LogManager.java:174)
    at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:618)
    at org.elasticsearch.common.logging.DeprecationLogger.<init>(DeprecationLogger.java:117)
    at org.elasticsearch.common.xcontent.support.AbstractXContentParser.<init>(AbstractXContentParser.java:57)
    at org.elasticsearch.common.xcontent.json.JsonXContentParser.<init>(JsonXContentParser.java:44)
    at org.elasticsearch.common.xcontent.json.JsonXContent.createParser(JsonXContent.java:108)
    at org.elasticsearch.common.xcontent.XContentHelper.convertToMap(XContentHelper.java:140)
    at org.elasticsearch.common.xcontent.XContentHelper.convertToMap(XContentHelper.java:114)
    at org.elasticsearch.common.xcontent.XContentHelper.convertToMap(XContentHelper.java:92)
    at org.elasticsearch.search.lookup.SourceLookup.sourceAsMapAndType(SourceLookup.java:89)
    at org.elasticsearch.search.lookup.SourceLookup.sourceAsMap(SourceLookup.java:93)
    at org.elasticsearch.search.SearchHit.getSourceAsMap(SearchHit.java:344)
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 6, 2019, 8:06am UTC](https://discuss.elastic.co/t/when-set-the-docvaluecontext-for-fetchphase-became-very-slow/175785/2 "2019-05-06T08:06:39Z")

</div>

Closed on May 6, 2019, 8:06am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
