-
Notifications
You must be signed in to change notification settings - Fork 2.4k
SplitBuilder.add(Flow) causes hung execution in some cases #3857
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
Comments
Thank you for reporting this issue and for providing a minimal example. I will let you know in which release this will be addressed. |
Spring Batch treats the two methods of adding flows to the
When Spring Batch traverses a flow structure with nested splits, it requires one thread for each nested It should be noted, that 10 threads are not enough to run all tasks in parallel. This requires at least 19 threads. With 10 available threads, Spring Batch will start with 5 parallel tasks and steadily reduce the number of parallel tasks until it starts the last task to run for itself as the other 9 threads are used by the nested For hundreds of tasks, it's probably easiest to add them all at once and control the level of concurrency with the thread core pool size. If you add them individually, you must increase the thread core pool size as described above. But then you loose effective control over the maximum number of parallel steps. @benas Have you already thought about how to address the issue? I think it would be a great enhancement, if the number of concurrent steps could be effectively controlled by the thread core pool size also in the presence of nested splits. |
@ee-usgs Thank you for reporting this issue and for providing a minimal example! This is a valid issue. Indeed, the execution hangs with multiple calls to @hpoettker Great analysis! Thank you for sharing that and for opening a PR 👍 The fact that Spring Batch behaves differently when adding all flows at once or adding them by using multiple calls to |
Bug description
If
FlowBuild.SplitBuilder.add(Flow)
is called multiple times to dynamically build a list of Flows, the result is a Flow that will hang.Calling
FlowBuild.SplitBuilder.add(Flow[])
with an array of Flows works as expected.For instance, this does not error, but does not work as expected:
However, this does work:
Why would you call
FlowBuild.SplitBuilder.add(Flow)
multiple times??I need to dynamically build my list of tasks - I don't know the size of the list or what the tasks are ahead of time. I do know, however, that they can all be run in parallel and there are a lot of them (hundreds). Calling
FlowBuild.SplitBuilder.add(Flow)
for each as I build up the list makes the most intuitive sense.Environment
Note: I'm pretty sure this is related to how SpringBatch works, not any sort of JDK issue.
SpringBatchCore 4.3.1
OpenJDK 12
Mac OS 10.14
Steps to reproduce
See the code example in GitHub, below.
The first flows runs as expected, the second flow hangs after two steps are executed.
Expected behavior
Calling
FlowBuild.SplitBuilder.add(Flow)
should just add to the list of flows to run in parallel. It shouldn't matter if they are added all at once or add is called multiple times.Minimal Complete Reproducible example
I created a Maven based demo project that shows this bug:
https://github.com/ee-usgs/springbatch_parallel_bug
This application should be runnable via Maven or any IDE.
The text was updated successfully, but these errors were encountered: