Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayIndexOutOfBoundsException in DoubleHistogram #1807

Open
shelliglick opened this issue Jan 19, 2020 · 3 comments
Open

ArrayIndexOutOfBoundsException in DoubleHistogram #1807

shelliglick opened this issue Jan 19, 2020 · 3 comments
Labels
bug A general bug waiting for feedback We need additional information before we can continue
Milestone

Comments

@shelliglick
Copy link

shelliglick commented Jan 19, 2020

Using micrometer + prometheus + reactor integration.

Getting this exception:

java.lang.ArrayIndexOutOfBoundsException: value outside of histogram covered range. Caused by: java.lang.ArrayIndexOutOfBoundsException: 64 at org.HdrHistogram.AbstractHistogram.handleRecordException(AbstractHistogram.java:428) at org.HdrHistogram.AbstractHistogram.recordCountAtValue(AbstractHistogram.java:405) at org.HdrHistogram.AbstractHistogram.recordValueWithCount(AbstractHistogram.java:344) at org.HdrHistogram.DoubleHistogram.recordCountAtValue(DoubleHistogram.java:317) at org.HdrHistogram.DoubleHistogram.recordValueWithCount(DoubleHistogram.java:280) at org.HdrHistogram.DoubleHistogram.add(DoubleHistogram.java:641) at org.HdrHistogram.DoubleHistogram.copyInto(DoubleHistogram.java:598) at org.HdrHistogram.DoubleRecorder.getIntervalHistogramInto(DoubleRecorder.java:176) at io.micrometer.core.instrument.distribution.TimeWindowPercentileHistogram.accumulate(TimeWindowPercentileHistogram.java:69) at io.micrometer.core.instrument.distribution.AbstractTimeWindowHistogram.accumulateIfStale(AbstractTimeWindowHistogram.java:173) at io.micrometer.core.instrument.distribution.AbstractTimeWindowHistogram.takeSnapshot(AbstractTimeWindowHistogram.java:163) at io.micrometer.core.instrument.AbstractTimer.takeSnapshot(AbstractTimer.java:188) at io.micrometer.prometheus.PrometheusTimer.takeSnapshot(PrometheusTimer.java:99) at io.micrometer.prometheus.PrometheusMeterRegistry.lambda$newTimer$2(PrometheusMeterRegistry.java:167) at io.micrometer.prometheus.MicrometerCollector.collect(MicrometerCollector.java:92) at io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.findNextElement(CollectorRegistry.java:183) at io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.nextElement(CollectorRegistry.java:216) at io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.nextElement(CollectorRegistry.java:137) at io.prometheus.client.exporter.common.TextFormat.write004(TextFormat.java:22) at io.micrometer.spring.autoconfigure.export.prometheus.PrometheusScrapeEndpoint.invoke(PrometheusScrapeEndpoint.java:50) at io.micrometer.spring.autoconfigure.export.prometheus.PrometheusScrapeEndpoint.invoke(PrometheusScrapeEndpoint.java:36) at org.springframework.boot.actuate.endpoint.mvc.AbstractEndpointMvcAdapter.invoke(AbstractEndpointMvcAdapter.java:56) at org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke(EndpointMvcAdapter.java:42) at io.micrometer.spring.autoconfigure.export.prometheus.PrometheusScrapeMvcEndpoint.invoke(PrometheusScrapeMvcEndpoint.java:30) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:854) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:765) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) at org.springframework.boot.actuate.autoconfigure.EndpointWebMvcChildContextConfiguration$CompositeHandlerAdapter.handle(EndpointWebMvcChildContextConfiguration.java:288) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) at javax.servlet.http.HttpServlet.service(HttpServlet.java:687) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748)

Using
reactor-core 3.2.10.RELEASE
micrometer-registry-prometheus 1.0.11
micrometer-spring-legacy 1.0.11
micrometer-core 1.0.11

Code snippet for adding histograms:

    @Bean
    public MeterFilter meterFilter() {
        return new MeterFilter() {
            @Override
            public DistributionStatisticConfig configure(Meter.Id id, DistributionStatisticConfig config) {
                if (id.getName().equals("reactor.flow.duration")) {
                    return DistributionStatisticConfig.builder()
                            .percentiles(0.5, 0.75, 0.95, 0.99)
                            .build()
                            .merge(config);
                }
                return config;
            }
        };
    }

(Tried also setting maximumExpectedValue and minimumExpectedValue explicitly, didn't help.)

I see 2 issues here :

  1. The DoubleHistogram.autoResize is set to true, while it's integerValuesHistogram is not.
  2. We would like to have the option to preconfigure the size of the allocated array (manually setting the highestToLowestValueRatio passed to the DoubleHistogram in it's ctor, according to the DistributionStatisticConfig.maximumExpectedValue)
@shelliglick
Copy link
Author

shelliglick commented Jan 19, 2020

opened a PR here #1808

@jkschneider
Copy link
Contributor

@shelliglick Since the default minimum/maximum expected values yield a highestToLowestValueRatio that HdrHistogram does not accept, I'm not sure what the right thing to do here is.

What values did your histogram see that caused the ArrayIndexOutOfBoundsException?

@shakuzen shakuzen modified the milestones: 1.1.12, 1.1.x Mar 30, 2020
@shakuzen shakuzen modified the milestones: 1.3.x, 1.5.x Jun 22, 2021
@shakuzen shakuzen modified the milestones: 1.5.x, 1.6.x Aug 12, 2021
@jonatan-ivanov jonatan-ivanov modified the milestones: 1.6.x, 1.7.x Nov 10, 2021
@shakuzen shakuzen modified the milestones: 1.7.x, 1.8.x May 11, 2022
@jonatan-ivanov jonatan-ivanov modified the milestones: 1.8.x, 1.9.x Jan 12, 2023
@marcingrzejszczak marcingrzejszczak added the waiting for feedback We need additional information before we can continue label Dec 22, 2023
@marcingrzejszczak
Copy link
Contributor

@shelliglick can you please help us replicate this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A general bug waiting for feedback We need additional information before we can continue
Projects
None yet
Development

No branches or pull requests

5 participants