Update Dead Sessions when Server Shutdown


Problem: in load balancing environment time-to-time sessions are dead in Active sessions pool. (ad_session.isProcessed=N). Actually Sessions are "deleted" when server started. (ad_session.isProcessed=Y - according to discussion with CarlosRuiz.)

Solution: We agree with CarlosRuiz would be solution to improve shutdown process by - similar to start session - to "clean ad_session"

IMPORTANT: server must process only related session, not other servers session.




Hiep Lq
May 11, 2016, 4:32 PM

hi , not only case use kill, it's cover case power suddenly turn off, or something make server crash or wrong network.

I see "ServerName column" but maybe i just think over. in test environment sometime you have to run muilti instance of idempiere on same PC

Carlos Ruiz
May 11, 2016, 4:58 PM

Yep - ServerName has more information, like port and IP I think.

So, if I understood in your approach other servers can mark sessions as finished when one server fails - is there one leading that task? Or all of them do it?
Can it be done as a scheduled process specific to an IP address? That checks (ping) the server in some way to see if is alive?

Hiep Lq
May 11, 2016, 5:07 PM

yes. it done at step 3
3. server will update active time of record each 5 minute (this value can configuration)

i create a new view to fill out session of server have active time > 5 minute (this value can configuration)
other server not need ping to check status of one server.

Carlos Ruiz
February 22, 2019, 3:07 PM

Revisiting this - I wonder if this can be done as a process, maybe using some kind of hazelcast broadcasting (like KillAllSession).

If this is done as a process then is easy to schedule it to run periodically.

However, I'm not sure if that's a good option to have by default - maybe better to have it as a plugin. There is always the risk of marking a session that is still alive but that was somehow disconnected from the hazelcast.


Carlos Ruiz

Norbert Bede
March 21, 2019, 7:40 PM

Hi Carlos,

yes this isgood to revisit and resolve.
we tried to implement count user sessions, but we totally fall while unpredictable dead sessions. so simple cant count.

i see 2 solutions now

1. from experience - users mostly login many times - various circumstances - after close browser, multiple computer login sessions with same user etc - usually session not finished correctly with logout. So they create new session record - and old - stalled - are not touched - we can apply a simple approach. When user login mark all previous - live/dead user sessions as done. This way user sessions are cleaned ongoing (similar when server is restarted). Here would be serious to broadcast a message you was kicked out while parallel login.

2. for periodic cleanup - eg nightly - process can be fine.

hope helps


Hiep Lq


Norbert Bede



Tested By