Is session lock for HeartBeat request required?

Hello,

We are getting a communication error when ever we execute a big query(that takes close to 3-4 min to get the data from the DB).
Please note that my heart beat interval is 1Min
. So, the use case works something like this - Firstly when ever we execute a query, we get hold of the session so that the user is not allowed to modify anything on the UI while query is being executed. So after 3 min the query returns and displays all the data in a table and my heartbeat request returns with 404 and a communication error is thrown on the UI.

On futher analyzing the problem, I got to know that the
heartbeat request
is waiting for the session lock to be released while the query is being executed. Once the session lock is released it is returning with a 404 error and hence the communication error.

Is it really required for the heartbeat to have a session lock?? as the only intention of it is to check if the server/session is alive or not.


Or is it a Bug in Vaadin 7.1.10

My Settings:

Vaadin - 7.1.10
HeartBeatInterval - 60 sec

Pls find attached a sample file that would help you in reproducing this problem

Thanks,
Krishna
13429.xml (2.16 KB)
13430.java (2.01 KB)

Yes, heartbeat requests must acquire the session lock because they access and modify the session state, namely, the “last accessed” timestamp in UI. There could be a finer-grained lock just for heartbeat, but that would needlessly increase complexity with little benefit. The session lock is not really meant for application-level synchronization, and holding it for many minutes is not at all recommended. Instead, I suggest simply setting the UI to disabled for the duration of the query (and notifying the user somehow that a long-running computation is in progress).

Hello Johannes,

Thank you for the reply, I have disabled the UI by using the combination of Z-index and loading indicator(when session is locked). But still, I don’t understand why my HeartBeat Request is returning 404 error once the query is executed.



I suggest simply setting the UI to disabled for the duration of the query (and notifying the user somehow that a long-running computation is in progress)

I will look in to this suggestion and will see how it can be incorporated in to our application.

To Overcome this problem, for timebeing, I am explictly handling HeartBeat request in my Overridden Servlet( just copy pasted the code from HeartBeatHandler)

Thanks,
Krishna.

The problem is that the heartbeat functionality works as expected :slight_smile: The heartbeats can’t get through for the duration of your query, so if the interval is 1 minute and the computation takes 3-4 minutes, it’s just enough time to cause the UI to miss the required three heartbeats and cause Vaadin to clean up the UI, thinking the client has gone away. After that, all client requests to the now-dead UI will fail.