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

ConcurrentModificationException in DefaultStateMachineExecutor #736

Closed
YusufKizilay opened this issue Apr 25, 2019 · 12 comments
Closed

ConcurrentModificationException in DefaultStateMachineExecutor #736

YusufKizilay opened this issue Apr 25, 2019 · 12 comments
Labels
type/bug Is a bug report
Milestone

Comments

@YusufKizilay
Copy link

Hi,

I am observing following exception from state machine on our production environment.
After that exception, state machine is stuck and never process subsequent request.

java.util.ConcurrentModificationException
at java.util.LinkedList$ListItr.checkForComodification(LinkedList.java:966)
at java.util.LinkedList$ListItr.next(LinkedList.java:888)
at org.springframework.statemachine.support.DefaultStateMachineExecutor.processDeferList(DefaultStateMachineExecutor.java:406)
at org.springframework.statemachine.support.DefaultStateMachineExecutor.access$200(DefaultStateMachineExecutor.java:61)
at org.springframework.statemachine.support.DefaultStateMachineExecutor$1.run(DefaultStateMachineExecutor.java:274)
at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
at org.springframework.statemachine.support.DefaultStateMachineExecutor.scheduleEventQueueProcessing(DefaultStateMachineExecutor.java:292)
at org.springframework.statemachine.support.DefaultStateMachineExecutor.execute(DefaultStateMachineExecutor.java:142)
at org.springframework.statemachine.support.AbstractStateMachine.sendEvent(AbstractStateMachine.java:232)

To reproduce same exception on my local environment , i am sending 1000 concurrent event to same state machine instance and same exception occurs and state machine is stuck. Right now, our production environment does not have a heavy load so i don't think 1000 or much more concurrent access cause our problem.

We are triggerring every event as a defer event which triggers actual event. Can someone help to investigate it?

@jvalkeal jvalkeal added this to the 2.1.3.RELEASE milestone Apr 30, 2019
@jvalkeal jvalkeal added the type/bug Is a bug report label Apr 30, 2019
@jvalkeal
Copy link
Contributor

Which version you're using? Just thinking if a fix needs to be backported.

@YusufKizilay
Copy link
Author

Thank you for response Janne. We are using 1.2.3.RELEASE version but i tried same case using latest version which is 2.1.2.RELEASE and i observed same exception.

@jvalkeal
Copy link
Contributor

jvalkeal commented May 2, 2019

Ok, I'll try to fix and backport to 2.0.x/1.2.x.

@jvalkeal
Copy link
Contributor

jvalkeal commented May 3, 2019

@YusufKizilay Could you check master, if that works for you I can backport this fix next week.

@jvalkeal jvalkeal changed the title ConcurrentModificationException when running statemachine ConcurrentModificationException in DefaultStateMachineExecutor May 3, 2019
This was referenced May 3, 2019
@YusufKizilay
Copy link
Author

Hi Janne, i tested the issue using master branch (version is 3.0.0.BUILD-SNAPSHOT) and state machine has behaved strange.

Sometimes when i send n concurrent event to a state machine instance, i observe related state action has triggerred 2xn time even 3xn time. And it is never ending.

But sometimes it is working correctly.

@jvalkeal
Copy link
Contributor

jvalkeal commented May 7, 2019

Remember that 3.x is currently going through some internal rewrites for reactive stories. I added a note to README that master may be super unstable.

@jvalkeal
Copy link
Contributor

jvalkeal commented May 7, 2019

Master was switched to 3.x last Saturday, current stable branch is 2.1.x.

@YusufKizilay
Copy link
Author

YusufKizilay commented May 7, 2019

If you think infinite loop problem is related to unstable branch, there is no problem right now .We are not getting exception and fix looks work.Please let me know, when you backport the fix to 1.2.x/2.0.x branch and it is ready to use.

@jvalkeal
Copy link
Contributor

jvalkeal commented May 7, 2019

Most likely, as I've seen some loops happening with this initial reactive work. Deferred events are slightly broken with new reactive executor which might end up in a loop.

@YusufKizilay
Copy link
Author

Hi Janne.
When we can use fix backported version( 1.2.3.RELEASE)?
Have you any guess about this?

jvalkeal added a commit that referenced this issue May 10, 2019
- Change deferList from LinkedList to ConcurrentLinkedQueue
  to fix ConcurrentModificationException with parallel events.
- Backport #736
- Relates #578
@jvalkeal
Copy link
Contributor

I'm doing 1.2.14.RELEASE today.

@jvalkeal
Copy link
Contributor

1.2.14.RELEASE now in spring repos and on its way to central.

jvalkeal added a commit that referenced this issue Jun 1, 2019
- Change deferList from LinkedList to ConcurrentLinkedQueue
  to fix ConcurrentModificationException with parallel events.
- Backport #736
- Relates #739
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Is a bug report
Projects
None yet
Development

No branches or pull requests

2 participants