Is there any I can do to prevent this exception?

From: Peter Turcsanyi <turcsa...@cloudera.com>
Sent: Friday, May 24, 2019 3:16 PM
To: users@nifi.apache.org
Subject: Re: java.lang.IllegalStateException: AsyncContext completed and/or 
Request lifecycle recycled ???

[CAUTION: This email originated from outside of Kodak Alaris. Do not click 
links or open attachments unless you recognize the sender and know the content 
is safe.]
________________________________
The request has a timeout configured on HttpContextMap. If there is some delay 
in the flow and the response is being processed around the expiration time, it 
can happen that the clean-up mechanism in HttpContextMap closes the expired 
request and sends 503 response to the client (while the response thread is 
still processing). You get this error when the response processor tries to 
complete the AsyncContext but it is already completed (AsyncContext is the 
context that wraps the asynchronous request / reponse).
It is a kind of race condition between the response processor and the clean-up 
threads. Recently I was thinking about adding some synchronisation logic for 
these threads, but in the end I decided not to do so because the examples I 
found ([1], [2]) do not handle it. The exception seems to me harmless, it just 
signs that there was a race condition.

[1] 
https://www.logicbig.com/tutorials/java-ee-tutorial/java-servlet/servlet-async.html<https://urldefense.proofpoint.com/v2/url?u=https-3A__www.logicbig.com_tutorials_java-2Dee-2Dtutorial_java-2Dservlet_servlet-2Dasync.html&d=DwMFaQ&c=skUQKLuTFULvQUMqV0uyBaBvPxsA7Wk8MKjvMTLjY3w&r=Wm89MSTpkAcFFP1M0uvGefI8slyO_VIaIza2IJwAlsU&m=JvznxQ7jbDiml8t8EUz0c7PdrjHhKPylIuPz8qYe7_8&s=8VbWuWOFH7BGQXCii5FpZBDSN9EFJHXek2RHSeuP9R8&e=>
[2] 
https://www.journaldev.com/2008/async-servlet-example<https://urldefense.proofpoint.com/v2/url?u=https-3A__www.journaldev.com_2008_async-2Dservlet-2Dexample&d=DwMFaQ&c=skUQKLuTFULvQUMqV0uyBaBvPxsA7Wk8MKjvMTLjY3w&r=Wm89MSTpkAcFFP1M0uvGefI8slyO_VIaIza2IJwAlsU&m=JvznxQ7jbDiml8t8EUz0c7PdrjHhKPylIuPz8qYe7_8&s=RzoNqLyaY6qKaQCAGpp6TKhpyvTKCjajxQcIvD8ZroE&e=>

On Fri, May 24, 2019 at 5:59 PM William Gosse 
<william.go...@aifoundry.com<mailto:william.go...@aifoundry.com>> wrote:
Does anyone know what this exception is about:

2019-05-23 19:09:07,102 ERROR [Timer-Driven Process Thread-2] 
o.a.n.p.standard.HandleHttpResponse 
HandleHttpResponse[id=d7b2feb7-4a1e-38c8-07b9-e3d9448bc92b] Failed to complete 
HTTP Transaction for 
StandardFlowFileRecord[uuid=423f4435-95ed-43fa-b03d-d1798a40f21e,claim=StandardContentClaim
 [resourceClaim=StandardResourceClaim[id=1558638515089-4, container=default, 
section=4], offset=127, length=129],offset=0,name=1500212603.pdf,size=129] due 
to java.lang.IllegalStateException: AsyncContext completed and/or Request 
lifecycle recycled: java.lang.IllegalStateException: AsyncContext completed 
and/or Request lifecycle recycled
java.lang.IllegalStateException: AsyncContext completed and/or Request 
lifecycle recycled
        at 
org.eclipse.jetty.server.AsyncContextState.state(AsyncContextState.java:54)
        at 
org.eclipse.jetty.server.AsyncContextState.complete(AsyncContextState.java:99)
        at 
org.apache.nifi.http.StandardHttpContextMap.complete(StandardHttpContextMap.java:142)
        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.apache.nifi.controller.service.StandardControllerServiceInvocationHandler.invoke(StandardControllerServiceInvocationHandler.java:87)
        at com.sun.proxy.$Proxy87.complete(Unknown Source)
        at 
org.apache.nifi.processors.standard.HandleHttpResponse.onTrigger(HandleHttpResponse.java:184)
        at 
org.apache.nifi.processor.AbstractProcessor.onTrigger(AbstractProcessor.java:27)
        at 
org.apache.nifi.controller.StandardProcessorNode.onTrigger(StandardProcessorNode.java:1162)
        at 
org.apache.nifi.controller.tasks.ConnectableTask.invoke(ConnectableTask.java:209)
        at 
org.apache.nifi.controller.scheduling.TimerDrivenSchedulingAgent$1.run(TimerDrivenSchedulingAgent.java:117)
        at org.apache.nifi.engine.FlowEngine$2.run(FlowEngine.java:110)
        at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
        at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
        at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
        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)

Reply via email to