OptaPlanner multi-threaded solution hangs

111 views
Skip to first unread message

Vilmos Nagy

unread,
May 1, 2021, 4:32:27 PM5/1/21
to OptaPlanner development
Hi there,

I've found a rather interesting bug, or TBH I'm not sure, if that's a bug.

I'm using OptaPlanner 8.1.0, and I haven't found any issue related to this - but if it's already fixd, or I'm missing something, I'd thank you if you could point to my mistake.

TLDR:
 - I've a custom MoveIteratorFactory
 - the factory tries to approx the size of the iterator, but it's just a quick approximation
 - aaand, if the MoveIterator is empty right after the creation (the first hasNext call returns false), OptaPlanner will hang at MultiThreadedConstructionHeuristicDecider:158 (it hangs after the forageResult calls resultQueue.take() method)

In this case my LocalSearch phase is hung, and even if I have a termination condition (eg an unimprovedscore setting, or a minutes spent termination), the phase won't terminate.

I've tried to return the extact number of the moves the iterator has - so the factory would return 0 if there will be no moves in the iterator, but it hangs even in this case.

My temp solution was to return some NoOpMoves in this case (which does nothing), and that solves my issue. But it's not a great solution.

My questions:
 - is it a known bug, and is it fixd? Should I update my OptaPlanner version?
 - should I create an MVCE, and report it in the Jira?
 - Is it illegal to have a custom move factory which has no moves?

Thanks for the help!

Regards,
Vilmos

Geoffrey De Smet

unread,
May 4, 2021, 4:23:46 AM5/4/21
to optapla...@googlegroups.com

Thank you for reporting.

1) I doubt it will fix it, but can you check if you can reproduce with 8.5.0.Final?
2) It doesn't reproduce with moveThreadCount=NONE? So its a pure multi-threaded bug?

With kind regards,
Geoffrey De Smet

--
You received this message because you are subscribed to the Google Groups "OptaPlanner development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to optaplanner-d...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/optaplanner-dev/93dc3013-2b44-461f-8eb2-c5ed5bdd8855n%40googlegroups.com.

Vilmos Nagy

unread,
May 6, 2021, 6:18:22 AM5/6/21
to OptaPlanner development
Hi Geoffrey


 - it happens with the latest snapshot version of OptaPlanner (I've forked the main repo today)
 - I cannot reproduce it with moveThreadCount=NONE

If you start the example app, and try to run the NQueens example, it'll hang.
But if you set this property to true, then the MoveIteratorFactory will generate some NoOpMoves, and the first localSearchPhase (created by me) ends normally.
Or if you set the moveThreadCount to NONE, then the first localSearchPhase ends normally as well.

Should I open a bug for this in your JIRA? Can I?

Regards,
Vilmos

Geoffrey De Smet

unread,
May 6, 2021, 10:59:38 AM5/6/21
to optapla...@googlegroups.com, Vilmos Nagy

Yes, anyone can open a bug report:

https://issues.redhat.com/projects/PLANNER

Please do create one.

With kind regards,
Geoffrey De Smet

Vilmos Nagy

unread,
May 7, 2021, 3:57:38 AM5/7/21
to OptaPlanner development
I've created the issue here: https://issues.redhat.com/browse/PLANNER-2414

Regards,
Vilmos

Geoffrey De Smet

unread,
May 25, 2021, 4:21:42 AM5/25/21
to optapla...@googlegroups.com

What happens if you give it twice or 4 times as much memory?

If you connection VisualVM, how does the memory graph look like and the GC churn rate look like?

With kind regards,
Geoffrey De Smet

chen jinhua

unread,
Oct 8, 2021, 9:03:59 PM10/8/21
to OptaPlanner development
hi, Vilmos. I think I met the same problem like yours in multi-thread  scene. This is  my problem, https://groups.google.com/g/optaplanner-dev/c/IBLvZOx3l20.  when I solved problems parallel,the first one terminate normally and the others are hang. could you please see my problem to check if they are the same?  In the other word, I don't know  whether I met the same bug or not.

chen jinhua

unread,
Oct 9, 2021, 5:35:45 AM10/9/21
to OptaPlanner development
i find the reason of my problem,  one of the custom MoveIteratorFactorys leads to the hanging of application. Thus, I comment the custom MoveIteratorFactorys, every thing ok.

Geoffrey De Smet

unread,
Oct 11, 2021, 2:57:43 AM10/11/21
to optapla...@googlegroups.com

Thanks for letting is know the issue isn't in optaplanner itself.

Vilmos, did you come to the same conclusion or do you have a reproducer you can share?

With kind regards,
Geoffrey De Smet

--
You received this message because you are subscribed to the Google Groups "OptaPlanner development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to optaplanner-d...@googlegroups.com.

Geoffrey De Smet

unread,
Oct 11, 2021, 2:58:36 AM10/11/21
to optapla...@googlegroups.com

Just found the reproducer in https://issues.redhat.com/browse/PLANNER-2414
Thanks Vilmos

With kind regards,
Geoffrey De Smet

Vilmos Nagy

unread,
Oct 11, 2021, 5:16:10 AM10/11/21
to OptaPlanner development
Hi Geoffrey,

TBH: We've put the project on hold where we used OptaPlanner a couple of months ago. 
As far as I remember our workaround was to return one NoOpMove from the factory which did nothing.
In any other case, the solver hung, as you can see in the MCVE.

Regards,
Vilmos

Reply all
Reply to author
Forward
0 new messages