Blocking issue in TaskCompletionImpl due to UiEventPublisher.publishEvent() (VaadinSession.lock)

Hi,

We’re using Jmix 2.5.2 with BPM, and we’ve run into a blocking issue related to UiEventPublisher.publishEvent() that is internally called by TaskCompletionImpl.complete().

When a user completes a BPM task, occasionally the request thread gets stuck trying to lock the VaadinSession.

Here is an excerpt from the thread dump:

"http-nio-8204-exec-1" #70
   java.lang.Thread.State: WAITING (parking)
   at com.vaadin.flow.server.VaadinSession.lock(VaadinSession.java:730)
   at io.jmix.flowui.sys.SessionHolder.getVaadinSessionState(SessionHolder.java:130)
   at io.jmix.flowui.sys.SessionHolder.getActiveSessionsForUsernames(SessionHolder.java:70)
   at io.jmix.flowui.UiEventPublisher.publishEventForUsersInternal(UiEventPublisher.java:91)
   at io.jmix.flowui.UiEventPublisher.publishEvent(UiEventPublisher.java:146)
   at io.jmix.bpmflowui.processform.TaskCompletionImpl.complete(TaskCompletionImpl.java:97)
   at io.jmix.bpmflowui.processform.TaskCompletionImpl.complete(TaskCompletionImpl.java:97)
   at at com.creas.fobombpm.view.cmftaskapprovalform.CmfTaskApprovalForm.onApproveBtnClick(CmfTaskApprovalForm.java:136)

In the attached full thread dump, I see a couple of threads blocked in UiEventPublisher.publishEvent() (line 146), all waiting for VaadinSession.lock().

The strange part is that this is not easy to reproduce.

  • In ~20 days, we saw around 5-6 “zombie” sessions stuck in this state.
  • During the same period, the system successfully processed maybe 10,000+ task completions without issue.
  • So it’s not deterministic (I cannot say “every time I approve a task, it happens”), but it does happen eventually.

In a previous project I faced a similar freeze when publishing UI events, and solved it by switching from UiEventPublisher.publishEvent() to publishEventForCurrentUi(). That avoided session locking issues.

I understand why publishEvent() is used here: in BPM it makes sense to notify all active sessions If one user completes the task, the task list in other user sessions should be updated immediately.

Thanks in advance.

threaddump.txt (2.3 MB)

Hi Mustafa,

Please try the solution described in Do not lock session to get its state · Issue #4632 · jmix-framework/jmix · GitHub and let us know about results.

Regards,
Konstantin

Hi Konstantin,

Thank you for the hint and for sharing the GitHub issue.

In production, we proposed this solution to the customer. Previously, I had also suggested an alternative — instead of publishing the task completion event to all sessions, they could publish only to the current UI and rely on manual refresh. For now, they decided to go with the manual refresh approach without trying the fix immediately.

They are planning a major upgrade in their test environment around October–November, and at that point, they suggested trying the solution you shared. Until then, they will continue with manual refresh in production.

Best regards,
Mustafa

Thank you for the update.
We’ll try to resolve this problem one way or another by the October release.

Regards,
Konstantin

1 Like