One run-away query and Vaadin's locked for that user? Threading Model

So I made a simple test app.
It had just one panel.
You click a button in that panel and it does a Thread.sleep() for 60 seconds.

During that 60 seconds, that user can’t do anything. This is expected.

What is NOT expected, is even if the user hits the browser refresh button, or even opens a whole new tab and re-visits the web app, they are stuck.

That user and browser cannot do anything at all with the app until that 60 second sleep finishes running.

I can imagine this is because Vaadin uses the same java object instances for the user and it must have some sort of synchronization code or something there.

I tested another browser (thus a different user) is able to load the app and is unaffected by User #1’s thread sleep.

The reason this is a big problem is, what if instead of a Thread.sleep(), what if that was a database query, and for whatever reason the query took several minutes to run (either due to being a slow query, or maybe the DB was flushing to disk and blocking, whatever).

I’m already over-riding getWindow() in Application so that each ‘browser tab’ they open is a separate Vaadin instance, but that code doesn’t seem to help at all in the run-away query example.

Does one single run-away query mean that the user is locked out of the app entirely until either the query finishes running or they close their browser and re-open their browser?

Start a new thread for long running tasks and then update the UI when the thread is done. See e.g. https://vaadin.com/forum/-/message_boards/view_message/231271. The UI won’t be blocked unless you choose to show a “please wait” dialog for instance, possibly with a “cancel” button that cancels the background thread.

Closing the window and opening it again leaves you waiting as all UI updates are done while synchronized to the Application instance and this is the same for all Windows in the session.

I’m worried about the long running tasks I don’t know about before hand.

I just KNOW that customers will end up calling up and say “The app keeps “locking up” and not even refreshing the browser lets them get back in. After a while it will let them back in”

Since it could be almost anything, it will be difficult to determine why.

I think it’s time I send an e-mail to management stating that if we choose Vaadin, we must also ensure that ALL tasks/queries either be optimized to never be slow, or run all possible long-running tasks/queries in a separate thread.

Thanks for the answer.

The rule of the wise, which has nothing at all to do with Vaadin really, is to thread any non-trivial database query and every web service call. And there should be a timeout – what if the database connection drops dead ? Systematic use of java.util.concurrency.FutureTask may save your day.