Service lock

Hi All,

Created a service which went in infinite loop because of coding issue, so i stopped the service in developer (but not yet killed, verified in IS service usage page). And modified the code again to avoid the infinite loop and ran the service but this time also service keeps running in developer also verified in service usage page. Why is that? I modified the code to avoid the infinite loop.

After server restart, without changing the code I ran service, this time it went fine since I modified before restart.

From this I understood, if we run a service which is running in infinite loop already, new service also goes into infinite loop, why is that? Correct me if am wrong? anyway to fix this? Can we say its a bug in webMethods?

Regards,
Sam.

Interesting perspective. :smiley: No I wouldn’t say that’s a bug in webMethods IS. I think you first comment -

is a better thing to call it. :wink:

Restarting the IS service as you did is the correct way to clear out the bad thread. You can’t really kill it while it’s running and simply saving a new version of the service is not going to cause Java to unload a running thread, do garbage collection to remove references to the old stuff, load the new thread and execute. :eek:

We have all done this, no big deal in dev process. Just restart the IS process and continue on. No bug though.

Hi Mark,

Thanks for your reply.

Consider that, service running in infinite loop because of wrong code & now I modified the code to avoid the infinite loop and re-run the service, does the service goes into infinite? now.

Note*: I didn’t kill the service which is in infinite loop[this is the code before modification & didn’t restart the IS].

Regards,
Sam

Sam,
I understand what you are doing but as I said you really can’t get rid of the active thread running in the JVM without restarting the IS process. That’s really not a webMethods IS issue, it’s more of a Java thing. Loading and unloading flow services and/or packages while they are currently executing is never a good thing either. webMethods IS will attempt to quiesce the service/package and associated active stuff but that’s not advisable either. That’s one reason you don’t deploy code to prod during active cycles.

Even if you were able to save the new flow service and get it to load and execute correctly you would still have the hung thread that is in an infinite loop running on your IS server. Best bet is to just restart your service. Also keep in mind that if you have flow service that is being fed by a broker trigger, simply restarting the IS process will not be enough to kill it. It will continue on startup of the IS process if the message is not marked volatile.

Hi Mark,

Hope I didn’t tell you clearly…

[
Consider that, service running in infinite loop because of wrong code & now I modified the code to avoid the infinite loop and re-run the service, does the service goes into infinite? now.

Note*: I didn’t kill the service which is in infinite loop[this is the code before modification & didn’t restart the IS].
]
Here, first service will be infinite loop until we do restart IS. No doubt in that… But, how about the service (i.e. the 2’nd service. The service which executed after modification/correction of the infinite loop code) whether this 2’nd service too goes into infinite loop? because of the 1’st service which is in infinite loop… Hope, now am clear in query… :slight_smile:

Regards,
Sam

The second version of the service was saved to disk but was not loaded into memory because IS/the JVM could not do so–the original version of the service was being used so it could not load the new and fixed version. Thus your run of the service the second time, ran using the original code–resulting in another thread in an infinite loop.

Your fixed service wasn’t loaded into memory until the IS restart.

Generally this shouldn’t be the case. right? So, some issue in IS or JVM. So whats the solution for this? always restarting IS is not the correct remedy, not intentionally writing the code in infinite loop…

Regards,
Sam.

Did you make changes to the code inside the loop or outside the loop? If changes are made outside loop to avoid infinite loop, it is not going to help as thread scope is currently within the loop. However if you have made chagnes inside loop to come out of infinite loop then it should help after saving the code.

Hi,

IS and JVM are working as expected here, although sometimes I also wish for the possibility to kill threads in IS. There are some approaches using Java code, but I’ve seen no reliable method so far. There is an entry on brainstorm which has staus planned, so this may come in the future.

However for your problem here Rob already pointed the important things out:

  • Correct your code to avoid infinite loops
  • Restart the IS JVM

Restarting IS may not be enough, so you should go for a complete stop of the underlying JVM.

Killing the IS JVM is the only reliable way so far to kill services which do not end themselfs.

One final note: Even if it would be possible to stop running services those should not go to infinite loops, this should be prevented by the code itself.