DWR

DefaultScriptSessionManager management of pageSessionMap

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Normal Normal
  • Resolution: Fixed
  • Affects Version/s: 2.0.9, 2.0.10, 3.0.RC2
  • Fix Version/s: 2.0.11, 3.0.RC3
  • Component/s: None
  • Documentation Required:
    No
  • Description:
    Hide
    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.
    Show
    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

Hide
David Marginian added a comment - 30/Jul/12 6:53 PM

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

Show
David Marginian added a comment - 30/Jul/12 6:53 PM See [dwr-dev] Management of page session map for more discussion.
Hide
David Marginian added a comment - 02/Aug/12 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

Show
David Marginian added a comment - 02/Aug/12 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
Hide
Geoff Johnston added a comment - 06/Aug/12 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.

Show
Geoff Johnston added a comment - 06/Aug/12 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.
Hide
Geoff Johnston added a comment - 06/Aug/12 2:56 PM

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

Show
Geoff Johnston added a comment - 06/Aug/12 2:56 PM I picked up the change to the invalidate method, and it works as expected to perform the needed cleanup. Many thanks!
Hide
David Marginian added a comment - 06/Aug/12 4:21 PM

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

Show
David Marginian added a comment - 06/Aug/12 4:21 PM Thanks for the response Geoff, glad it is working for you.

People

Dates

  • Created:
    30/Jul/12 2:01 PM
    Updated:
    06/Aug/12 4:21 PM
    Resolved:
    02/Aug/12 4:45 PM