DefaultScriptSessionManager management of pageSessionMap

Description

On a production application using DWR 2.0.9, I noticed that the number of entries in DefaultScriptSessionManager's pageSessionMap increases forever. This application's use of Spring Webflow 1.0.4 (old!), causes it to continually generate new unique URLs, each time a flow is entered by a user. As a result, I'm seeing tens of thousands of entries in pageSessionMap, which appears to degrade performance. In a 'normal' app, I'd expect the number of unique URLs for an app to be fairly limited. Here's an example of the created URLs:
https://localhost/myapp/flow/k/_c6F312258-F407-3BDF-5B73-17E4C5A92C3E_kE1D31343-C3A5-EAB1-B429-9CF977225DA4
https://localhost/myapp/flow/k/_c4AEBE1D6-D0F9-5951-40F4-CE82FB8B76E9_kF8BEFBCB-3B39-6CD5-40FF-6E864E78F4A3

The unique flow ID isn't part of the query string, so it's not stripped by PageNormalizer.normalizePage.

Just to be clear, inactive sessions are being invalidated/removed from sessionMap (based on the default 5 minute check), but entries in pageSessionMap itself are never removed.
The invalidate method iterates over pageSessionMap, and for each entry (a set), removes the scriptSession from that set. But once that set becomes size zero, nothing ever removes the empty set from pageSessionMap.
This lack of cleanup is probably only an issue for applications that service a large number of URLs (as with older versions of spring webflow).

My observation of this has been based on looking at the 2.0.9 code and tests of the application on that version. I am marking this as 'affects versions' 2.0.9 and 2.0.10 (really 2.0.X), as well as 3.0.RC2, though I have not confirmed the same behavior on the latter, and DefaultScriptSessionManager has changed around significantly enough that I'm unsure if it's still an issue.

In the meantime, I am able to work around this, with an alternate implementation for method invalidate that removes the pageSessionMap entry when its session set is empty.

Activity

Show:
David Marginian
July 30, 2012, 6:53 PM

See [dwr-dev] Management of page session map for more discussion.

David Marginian
August 2, 2012, 4:44 PM
Edited

Geoff, try out the latest 2.x build on our bamboo server and let me know if you find any issues: http://ci.directwebremoting.org/bamboo/allPlans.action

GeoffreyJ
August 6, 2012, 11:22 AM

David - thanks and sorry for the delay - was otherwise occupied late last week. Should be able to try it out against our codebase this week.

GeoffreyJ
August 6, 2012, 2:56 PM

I picked up the change to the invalidate method, and it works as expected to perform the needed cleanup. Many thanks!

David Marginian
August 6, 2012, 4:21 PM

Thanks for the response Geoff, glad it is working for you.

Assignee

David Marginian

Reporter

GeoffreyJ

Labels

None

Documentation Required

No

Fix versions

Affects versions

Priority

Normal
Configure