Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-14891

Race condition using toD

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.2.0
    • Fix Version/s: 3.3.0
    • Component/s: camel-metrics
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      I'm not sure which components are affected by this. I noticed this with the metrics component but it might be a general issue. Consider these two stack traces:

       

      {{"Camel (camel-1) thread #7 - my-thread-1"}}
      {{ {{ at org.apache.camel.component.metrics.MetricsComponent.doInit(MetricsComponent.java:137)}}}}
      {{ {{ at org.apache.camel.support.service.BaseService.init(BaseService.java:83)}}}}
      {{ {{ at org.apache.camel.support.service.BaseService.start(BaseService.java:111)}}}}
      {{ {{ at org.apache.camel.impl.engine.AbstractCamelContext.startService(AbstractCamelContext.java:3056)}}}}
      {{ {{ at org.apache.camel.impl.engine.AbstractCamelContext.getComponent(AbstractCamelContext.java:537)}}}}
      {{ {{ at org.apache.camel.impl.engine.AbstractCamelContext.getComponent(AbstractCamelContext.java:500)}}}}
      {{ {{ at org.apache.camel.impl.engine.AbstractCamelContext.doGetEndpoint(AbstractCamelContext.java:831)}}}}
      {{ {{ at org.apache.camel.impl.engine.AbstractCamelContext.getEndpoint(AbstractCamelContext.java:769)}}}}
      {{ {{ at org.apache.camel.support.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:72)}}}}
      {{ {{ at org.apache.camel.support.ExchangeHelper.resolveEndpoint(ExchangeHelper.java:114)}}}}
      {{ {{ at org.apache.camel.support.ExchangeHelper.resolveEndpoint(ExchangeHelper.java:92)}}}}
      {{ {{ at org.apache.camel.processor.SendDynamicProcessor.resolveEndpoint(SendDynamicProcessor.java:289)}}}}
      {{ {{ at org.apache.camel.processor.SendDynamicProcessor.process(SendDynamicProcessor.java:157)}}}}
      {{ {{ at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.run(RedeliveryErrorHandler.java:395)}}}}
      {{ {{ at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:148)}}}}
      {{ {{ at org.apache.camel.impl.engine.DefaultReactiveExecutor.schedule(DefaultReactiveExecutor.java:55)}}}}
      {{ {{ at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.lambda$run$0(RedeliveryErrorHandler.java:398)}}}}
      {{ {{ at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask$$Lambda$742.2026232778.done}}}}
      {{ {{ at org.apache.camel.processor.ThreadsProcessor$ProcessCall.run(ThreadsProcessor.java:88)}}}}
      {{ {{ at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)}}}}
      {{ {{ at java.util.concurrent.FutureTask.run(FutureTask.java:266)}}}}
      {{ {{ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)}}}}
      {{ {{ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)}}}}
      {{ {{ at java.lang.Thread.run(Thread.java:748)}}}}{{"Camel (camel-1) thread #8 - my-thread-2"}}
      {{ {{ at org.apache.camel.component.metrics.MetricsComponent.createEndpoint(MetricsComponent.java:60)}}}}
      {{ {{ at org.apache.camel.support.DefaultComponent.createEndpoint(DefaultComponent.java:233)}}}}
      {{ {{ at org.apache.camel.impl.engine.AbstractCamelContext.doGetEndpoint(AbstractCamelContext.java:842)}}}}
      {{ {{ at org.apache.camel.impl.engine.AbstractCamelContext.getEndpoint(AbstractCamelContext.java:769)}}}}
      {{ {{ at org.apache.camel.support.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:72)}}}}
      {{ {{ at org.apache.camel.support.ExchangeHelper.resolveEndpoint(ExchangeHelper.java:114)}}}}
      {{ {{ at org.apache.camel.support.ExchangeHelper.resolveEndpoint(ExchangeHelper.java:92)}}}}
      {{ {{ at org.apache.camel.processor.SendDynamicProcessor.resolveEndpoint(SendDynamicProcessor.java:289)}}}}
      {{ {{ at org.apache.camel.processor.SendDynamicProcessor.process(SendDynamicProcessor.java:157)}}}}
      {{ {{ at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.run(RedeliveryErrorHandler.java:395)}}}}
      {{ {{ at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:148)}}}}
      {{ {{ at org.apache.camel.impl.engine.DefaultReactiveExecutor.schedule(DefaultReactiveExecutor.java:55)}}}}
      {{ {{ at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.lambda$run$0(RedeliveryErrorHandler.java:398)}}}}
      {{ {{ at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask$$Lambda$742.2026232778.done}}}}
      {{ {{ at org.apache.camel.processor.ThreadsProcessor$ProcessCall.run(ThreadsProcessor.java:88)}}}}
      {{ {{ at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)}}}}
      {{ {{ at java.util.concurrent.FutureTask.run(FutureTask.java:266)}}}}
      {{ {{ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)}}}}
      {{ {{ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)}}}}
      {{ {{ at java.lang.Thread.run(Thread.java:748)}}}}

       

      As you can see, thread #8 tries to create an endpoint from the metrics component while thread #7 is still initializing it. This causes endpoinds to be created from uninitialized components.

       

      Both threads are working on the same node in the same route, which is defined using the DSL:

      .toD("metrics:counter:request.${headers.product}-xcount?increment=1")

        Attachments

          Activity

            People

            • Assignee:
              davsclaus Claus Ibsen
              Reporter:
              atreffer Arian Treffer
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: