Scriptrunner Listener - Fire-and-Forget

Niklas Spletter-Enning January 26, 2021

Hi Community!

I am calling an IBM Cloud Function (FaaS) from my Scriptrunner Listener (on Issue Commented Event). Unfortunately the cloud function does not send a response (since it is capsuled in a docker container). As a result the listener crashes and the whole JIRA server instance goes down, due to blocked threads I assume.

BUT: When I call the same IBM Cloud Function from the Scriptrunner Script Console the function is triggered, works smooth and JIRA does not complain.

I assume this is because the Console works on Fire-and-Forget and the Listener does not.

Therefore my question: Can I code the listener or the specific http function call  in a Fire-and-Forget manner?

Thank you for your help!

 

Cheers

Niklas

1 answer

1 accepted

0 votes
Answer accepted
Benz Kek _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 26, 2021

Hi Niklas, 

Regarding your question, I would foresee the same issue will happen in Script Console if the IBM Cloud Function didn't respond and the Script Console would keep running as it is. The difference is that Script Console runs on the main thread while Listener often runs on another thread.

Having said that, I would suggest adding some timeout to your HTTP function call instead. That should suffice to tackle the scenario where your function didn't respond and the thread will self-terminate after a time period. 

Niklas Spletter-Enning January 27, 2021

Hi Benz,

thanks for your input!

Unfortunately I can say with certainty that the function call works fine from the Script Console :O

I think the thread issue goes into the right direction. Even though I do not know how to handle it. Would it be an idea to call the cloud function from an async thread?

I will try to play around with the HTTP function timeout and see if it works.

I can see the following entry in the atlassian-jira.log several times right before the instance goes down:

2021-01-25 11:15:53,819+0000 FelixShutdown ERROR [o.e.g.b.e.i.util.concurrent.RunnableTimedExecution] Closing runnable for context NonValidatingOsgiBundleXmlApplicationContext(bundle=com.onresolve.jira.groovy.groovyrunner, config=osgibundle:/META-INF/spring/*.xml) did not finish in 500ms; consider taking a snapshot and then shutdown the VM in case the thread still hangs

 

Does this add any information to our brainstorming which is helpful do understand why the whole instance crashes?

 

Thank you!

 

Cheers

 

Niklas

Benz Kek _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 30, 2021

Yes, the async thread will definitely help so that it doesn't crash your Jira main thread. However, if the async thread gets stuck too, it will still crash your server. 

The error you shared is indicating that the thread is indeed stuck/hangs. You can try using Groovy's AsyncHTTPBuilder, it should allow you to set timeout to an HTTP request. 

I hope the above helps! 

Like Niklas Spletter-Enning likes this
Benz Kek _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 2, 2021

Hi @Niklas Spletter-Enning thanks for the like in my reply. Please do accept the answer so that we can mark this community post as Solved. 

Thank you! :) 

Suggest an answer

Log in or Sign up to answer